powershellazure-web-app-serviceazure-powershellazure-cliazure-cli2

How to Get All the Containers From a Specific Azure Storage Account using Azure CLI?


How to Get All the Containers From a Specific Azure Storage Account using Azure CLI? How to set context in azure cli like we set context in Powershell? $ctx = $storageAccount.Context

How can we achieve this using Azure CLI?

Get the storage account from which container has to be retrieved

Get the storage account context

List all the containers


Solution

  • Get All the Container list

    az storage container list --account-name <Storage Account Name> --account-key <Storage Account Key> --query "[].{Name:name}" --output table
    

    enter image description here

    Set & Get Context

    # example to set the Az context
    Set-AzContext -Subscription  "XXXX-XXXX-XXXX-XXXX"
    

    Refer Set AzContext & Get AzContext