Azure Storage Actions is a powerful platform for automating data management tasks across Blob and Data Lake Storage. Among its many features, Exclude Prefix stands out as a subtle yet critical capability that helps fine-tune task assignments.
What Is the "Exclude Prefix" Feature?
The Exclude Prefix option allows users to omit specific blobs or folders from being targeted by Azure Storage Actions. This is particularly useful when applying actions such as:
- Moving blobs to a cooler tier
- Deleting blobs
- Rehydrating archived blobs
- Triggering workflows based on blob changes
For example, if you're running a task to archive blobs older than 30 days, but you want to exclude logs or config files, you can define a prefix like logs/ or config/ in the exclusion list.
How to Use It — Example Scenario:
In the following example, blobs across the entire storage account were deleted based on a condition: if a blob’s access tier was set to Hot, it was deleted except for those blobs or paths explicitly listed under the Exclude blob prefixes property.
- Create a Task: -
- Navigate to the Azure portal and search for Storage tasks. Then, under Services, click on Storage tasks – Azure Storage Actions
-
- On the Azure Storage Actions | Storage Tasks page, click Create to begin configuring a new task.
- On the Azure Storage Actions | Storage Tasks page, click Create to begin configuring a new task.
-
- Complete all the required fields, then click Next to proceed to the Conditions page. To configure blob deletion, add the following conditions on the Conditions page.
- Add the Assignment :-
- Click Add assignment in the Select scope section, choose your subscription and storage account, then provide a name for the assignment.
- In the Role assignment section, select Storage Blob Data Owner from the Role drop-down list to assign this role to the system-assigned managed identity of the storage task.
- In the Filter objects section, specify the Exclude Blob Prefix filter if you want to exclude specific blobs or folders from the task.
- Click Add assignment in the Select scope section, choose your subscription and storage account, then provide a name for the assignment.
In the example specified above, blobs will be deleted—except for those under the path “excludefiles” listed in the Exclude blobprefixes property.
-
- In the Trigger details section, choose the runs of the task and then
select the container where you'd like to store the execution reports. - Select Add. In the Tags tab, select Next and in the Review + Create tab, select Review + create.
- When the task is deployed, your deployment is complete page appears and select Go to resource to open the Overview page of the storage task.
- In the Trigger details section, choose the runs of the task and then
- Enable the Task Assignment: -
- In the Trigger details section, we have a Enable task assignment checkbox which is checked by default.
-
- If the Enable task assignments checkbox is unchecked, you can still enable assignments manually from the Assignments page. To do this, go to Assignments, select the relevant assignment, and then click Enable.
The task assignment is queued to run and will run at the specified time.
- Monitoring the runs:-
After the task completes running, you can view the results of the run.
- With the Assignments page still open, select View task runs.
- Select the View report link to download a report. You can also view these comma-separated reports in the container that you specified when you configured the assignment.
- With the Assignments page still open, select View task runs.
Conclusion:
The Exclude Prefix feature in Azure Storage Actions provides enhanced control and flexibility when managing blob data at scale. By allowing you to exclude specific prefixes from actions like delete or tier changes, it helps you safeguard critical data, reduce mistakes, and fine-tune automation workflows. This targeted approach not only improves operational efficiency but also supports more granular data in Azure Blob Storage.
Note:-
- Azure Storage Actions are generally available in the following public regions: https://learn.microsoft.com/en-us/azure/storage-actions/overview#supported-regions
- We can also exclude certain blobs using the “Not”operator when building task conditions. Blobs may be excluded based on specific blob or container attributes from the task conditions side as well—not just through task assignments.
In the screenshot below, we are using the Not operator (!) to exclude blobs where the blob name is equal to "Test".
Please refer: https://learn.microsoft.com/en-us/azure/storage-actions/storage-tasks/storage-task-conditions#multiple-clauses-in-a-condition.
Reference Links:-