Delete/Update Retention policy on blob storage account

sachin gupta 376 Reputation points
2022-06-29T01:36:32.337+00:00

Hi Team,
I created a retention policy in UAT environment using below code snippet.
Code-

Create a new action object.

$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete `
-daysAfterModificationGreaterThan 180

Create a new filter object.

$filter = New-AzStorageAccountManagementPolicyFilter -PrefixMatch token/ `
-BlobType blockBlob

Create a new rule object.

$rule1 = New-AzStorageAccountManagementPolicyRule -Name sample-rule -Action $action
-Filter $filter

Create the policy.

Set-AzStorageAccountManagementPolicy -ResourceGroupName $rgName -StorageAccountName $accountName
-Rule $rule1

The retention policy created fine for Blob name 'token'.
Below are my questions-

  1. how we can delete/update this retention policy from UAT through PowerShell, as we don't have access to delete it from azure portal.
  2. when I tried to create this retention policy to apply the filters and rules for a 3 blob containers named- token, AT, Stage. using prefix match as token/, AT/, Stage/ it started giving error.
    Error - cannot process command because of one or more missing mandatory parameters: Rule

Please provide your input on this.
Thank you

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,540 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,082 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.