N.avraham
N.avraham

Reputation: 343

For how long does a blob persist in azure storage account?

I have created a storage account in azure portal, and a streamanalytics job that sends query results to a blob in that storage account.

I wish to know - for how long will that data be kept in that blob? Is there a default period of time when the blob will be deleted automatically? Is there a way for me to configure when to delete the blob content in my account?

Upvotes: 1

Views: 2304

Answers (3)

Mike
Mike

Reputation: 240

Azure Blob Storage Lifecycle Management is now Generally Available.

From Powershell, you can create a policy that deletes blobs after 90 days like this:

#set up variables
$rgname = 'test-rg'
$accountName = 'test-storage'

# create an action
$action = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -daysAfterModificationGreaterThan 90
#create a rule
$rule1 = New-AzStorageAccountManagementPolicyRule -Name Test -Action $action
#apply the rule to a storage account
$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $accountName -Rule $rule1

For more info: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-lifecycle-management-concepts

Upvotes: 0

Fei Han
Fei Han

Reputation: 27793

how long will that data be kept in that blob? Is there a default period of time when the blob will be deleted automatically?

As Peter Bons said, currently Azure Blob storage do not allow us to define expiration policies on Blobs.

Is there a way for me to configure when to delete the blob content in my account?

There are no direct way to configure Azure storage or Blobs to make Azure storage automatically delete “expired” Blobs. As we know, azure storage blob enable us to create a virtual directory structure by including path information in blob name and Stream Analytics enable us to specify the naming convention of files being sent to Azure Blob Storage, so you could specify Path Prefix Pattern to include datetime info in blob name, and then you could create a scheduled WebJob and detect Blobs in the specified container and delete Blobs based on datetime info included in blob name.

Upvotes: 0

Peter Bons
Peter Bons

Reputation: 29780

It stays the as long as the subscription is paid for. There is a populair vote to create some kind of retention policy but AFAIK it is not available yet. So you will have to write your own logic if you need to have it deleted after a certain period.

Upvotes: 3

Related Questions