How to find backup vaults for an Azure blob container and file share using AZ CLI?

ThePowershellFan-4984 1 Reputation point

I'm working on an automation project where I need to find the backup vaults configured for blob container and file share. I searched Microsoft documents but couldn't find anything to achieve my goal. Could anyone please help?


Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,175 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,731 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,468 questions
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
324 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 3,901 Reputation points

    Hello @ThePowershellFan-4984

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    You are in need of Azure CLI to find the backup vaults configured for blob container and file share.

    Most of all, so sorry for not being able to find Microsoft documents to achieve my goal at that time.

    Now, here we go! If you want to manage the backups or backup-related configurations for Blob Containers and File Shares, you need to work with the Azure Backup service for Blob Containers and Azure File Sync for File Shares.

    Below are the ways on how you can work with Azure Backup and find the backup vaults configured for Blob Containers and Azure File Sync for File Shares using the Azure CLI:

    1. First, you need to list all the backup items in your resource group and vault name using the command: az backup item list --resource-group <resource-group-name> --vault-name <vault-name> This will return a JSON output with the details of each backup item, such as the container name, friendly name, type, policy name, and recovery point count.
    2. Azure Backup for Blob Containers, to list Azure Backup vaults: az backup vault list --resource-group <resource-group-name>
    3. Azure File Sync for File Shares, to list Azure File Sync services: az sync list --resource-group <resource-group-name>

    There are many things you can do with your output. You can filter the output by the container name and the friendly name that match your blob container and file share names.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

  2. ThePowershellFan-4984 1 Reputation point

    Hello Sina,

    Thank you so much for your answer.

    Azure handles backups for blob containers and file shares differently:

    1. Blob containers: Azure data protection is used. MS made a command to do the work:
      az dataprotection backup-instance list-from-resourcegraph --datasource-type AzureBlob --datasource-id $RecourceID
    2. File shares: Azure backup is used. Unfortunately, MS doesn't have a similar CLI command for it, at least I didn't find it. Your answer is limiting the vaults are located in a known resource group, but from an automation script, we don't know this info. Here is what I have:
    3. list all vaults in the subscription:
      az backup vault list --subscription $subscription_id
    4. for each vault, list all backup containers in the vault:
      az backup container list --backup-management-type AzureStorage --vault-name $vault_name --resource-group $resource_group
      Then search for the container which matches the storage account that being backed up.

    Above answers have been tested working.

    Thank you for your support.

    0 comments No comments