Retrieve a storage context with ARM
Learn how to get a storage context for an ARM storage account.
John Savill
June 19, 2016
1 Min Read
Q. How do I retrieve a storage context to an ARM storage account?
A. Azure Resource Manager handles resources very differently from Azure Service Manager however for PowerShell cmdlets that use a storage context based on the storage account key (or using a shared access signature (SAS)) and the storage account name. The PowerShell below fetches the storage account key and creates a context that could then be used for any storage cmdlet that uses contexts such as copy operations and Azure Files.
$AzStorAccName = 'savtechsalrsscus'$AzResGroup = 'rg-scusa'$AzStrAct = Get-AzureRmStorageAccount -Name $AzStorAccName -ResourceGroupName $AzResGroup$AzStrKey = Get-AzureRmStorageAccountKey -Name $AzStorAccName -ResourceGroupName $AzResGroup$AzStrCtx = New-AzureStorageContext $AzStorAccName -StorageAccountKey $AzStrKey[0].Value#Example creation of Azure Files share with the storage context created$imgs = New-AzureStorageShare imgs -Context $AzStrCtx
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like