Skip to content

[Storage] Support container softdelete #15284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2021

Conversation

blueww
Copy link
Member

@blueww blueww commented Jun 16, 2021

Description

design pass review in: Azure/azure-powershell-cmdlet-review-pr#726

Add a static analysis exception for -RetentionDays. This is already discussed in design review and the name agreed.

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:
    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

@blueww blueww force-pushed the containersoftdeletega branch from fa70f61 to 24e6c72 Compare June 16, 2021 09:31
Copy link
Contributor

@BethanyZhou BethanyZhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @blueww , please submit a cmdlet design for new added cmdlets.
For Enable-AzStorageContainerDeleteRetentionPolicy and Disable-AzStorageContainerDeleteRetentionPolicy,
I suggest we combine them as one cmdlet, for instance Update-AzStorageContainer [DeleteRetentionPolicy <switch>].

Comment on lines 784 to 812
$stos = Get-AzStorageAccount -ResourceGroupName $rgname;

# Enable Blob Delete Retention Policy
$policy = Enable-AzStorageContainerDeleteRetentionPolicy -ResourceGroupName $rgname -StorageAccountName $stoname -PassThru -RetentionDays 30
Assert-AreEqual $true $policy.Enabled
Assert-AreEqual 30 $policy.Days
$property = Get-AzStorageBlobServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual $true $property.ContainerDeleteRetentionPolicy.Enabled
Assert-AreEqual 30 $property.ContainerDeleteRetentionPolicy.Days

# Create and delete container, then get container
$contaierName = "testcontaienr"
New-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $contaierName
Remove-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $contaierName -Force
$cons = Get-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual 0 $cons.Count
$cons = Get-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -IncludeDeleted
Assert-AreEqual 1 $cons.Count
Assert-AreEqual $contaierName $cons[0].Name
Assert-AreEqual $true $cons[0].Deleted


# Disable Blob Delete Retention Policy
$policy = Disable-AzStorageContainerDeleteRetentionPolicy -ResourceGroupName $rgname -StorageAccountName $stoname -PassThru
Assert-AreEqual $false $policy.Enabled
$property = Get-AzStorageBlobServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual $false $property.ContainerDeleteRetentionPolicy.Enabled

Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @blueww , please correct indents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

$containerNamesoftdelete = "softdeletecontainer"
New-AzStorageContainer -Name $containerNamesoftdelete -Context $storageContext
Remove-AzStorageContainer -Name $containerNamesoftdelete -Context $storageContext -Force
## Get container without -IncludeDeleted, won't list out deleted containers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct indents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@blueww
Copy link
Member Author

blueww commented Jun 17, 2021

@BethanyZhou

For Enable-AzStorageContainerDeleteRetentionPolicy and Disable-AzStorageContainerDeleteRetentionPolicy, they are alredy in https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/726.
I would suggest not combine them, since:

  1. We use enable/disable-* cmdlets for many other blob service properties like blob softdelete, and we would like to keep aligned.
  2. We already release this feature in preview module, and would like to keep same behavior with preview module to avoid user breaking

@BethanyZhou
Copy link
Contributor

Make sense.

@BethanyZhou
Copy link
Contributor

/azp run azure-powershell - windows-powershell

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@BethanyZhou BethanyZhou merged commit 3cd8d07 into Azure:main Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants