Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Azure PowerShell Get-AzStorageShare Could not get the storage context

While working with Azure Storage Account Shares report, while running below Azure az PowerShell command to get shares list, it was throwing error.

Get-AzStorageShare -Name testbackup
Get-AzStorageShare: could not get the storage context. Please pass in a storage context or set the current storage context.

Microsoft Azure az Get-AzStorageShare could not get the storage context. Please pass in a storage context or set the current storage context.png

Solution: To resolve this error message and get the information about shares, you will need to use storage account as context in the shares, as shown in below one liner command.

Get-AzStorageShare -Name <ShareName> -Context (Get-AzStorageAccount -Name <StorageAccountName> -ResourceGroupName <ResourceGroupName>).context

Get-azstorageaccount microsoft azure az commands get-azstorageshare context endpoint file.core.windows.net snapshot container.png

Useful Articles
Create key vault and secrets with access policies in Microsoft Azure
Working With Azure Key Vault Using Azure PowerShell and AzureCLI
Use Key Vault secret identifier url to get the secret value using Powershell
Use a Azure VM system assigned managed identity to access Azure Key Vault
Create Azure Key Vault Certificates on Azure Portal and Powershell
Export certificates from Azure Key Vault using PowerShell

Go Back

Comment

Blog Search

Page Views

8574352

Follow me on Blogarama