Using Azure Storage Actions
Azure Storage Actions help us perform large scale actions on blobs across one or more storage accounts from a singular serverless resource. Unlike needing to create an Azure Function, or the manual execution of a Powershell script or a maybe web job, the task is carried out in a way that evolves with the Azure platform and 'should not' require updates to the implementation over time (as seen with Azure Functions and its runtimes becoming out of support as Azure evolves). The most common way to manipulate blobs would have been generally Timer or Blob Storage triggered Functions. This new implementation of Azure Storage Actions offers a new strategy on this.
The Azure Storage Action will have its own resource in a specific region, and therefore your target storage account where your blobs live must be in the same region for this to work properly, there is no support for the Storage Action being able to manipulate data in a storage account in a different region (yes I was confused for a while myself🤔). At the time of writing, Azure Storage Actions are in preview.
Let's set up one here in this blog and target one storage account to test!!
Create Azure Storage Action resource
In the Azure Portal, search for Azure Storage Actions and create the resource in a supported Region (this is preview at the time of writing) for your target resource. Set a Storage task name and click Next:
Set the Storage Task conditions
Let's take a quick look at the following Storage Task
This Storage Task will simply take a look at all blobs that meet the conditions of being more than 10MB (the blob Content Length or size is set in bytes) plus containing the .mp4 extension in the name, and then will set the blob tier to 'Cool'. This means those blobs will be moved to slower read access storage in Azure, reducing our general 'at rest' costs for these particular blobs.
Click Next and also skip over Assignments and Tags for now by clicking Next (this will come later), then Review and Create the Storage Action resource:
Add Storage Task Assignment to a storage account
You now need to add an 'assignment' to the Task you have just made to allow it to run on a specific storage account.
Click on Configure Assignment, then Add Assignment. Set your details as the following for example, noting that the storage accounts that appear here are accounts in the same region as the Storage Action you are creating:
It is important to note that for the above screenshot, it will be cost effective to try and limit what is assessed to a specific blob container prefix. You can add further multiple assignments for different containers perhaps for clearer distinction. If you happened to have millions of blobs or containers, the run would take quite long to scan all files, and you would be charged for all of those read operations!! Scope your containers carefully.
Scrolling further down, add a schedule or set a singular run for the assignment and click Add:
After the assignment is created and when you are ready, you must Enable it in the Ellipsis menu in the assignment here:
Results
After the scheduled time of the Action, refresh the the Assignments blade to see what happened under View Task runs
This result above indicates that within my 'media' storage container in the storage account, 2 files matched my Conditions that were set earlier, whilst 7 other files were assessed but did not satisfy the Conditions. Once again, remember there will be storage read operation costs associated with this although fairly small (in my case, for my 9 files).
And sure enough, when we observe the 2 updated files, their Access tier has been changed to Cool where they were initially uploaded as Hot:
Clean up Resources
As always, remember to clean up any unused resources in Azure!!