Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Last active October 7, 2016 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephlocke/db3c0d0decc714fe36ee6e1b9770007e to your computer and use it in GitHub Desktop.
Save stephlocke/db3c0d0decc714fe36ee6e1b9770007e to your computer and use it in GitHub Desktop.
How to get container details from a storage account stored in an azure resource group
Import-Module AzureRM.Storage
$rgname="group"
$StorageAccountName="storage"
$container="container"
# getting Azure storage account key
$fullkeys = Get-AzureRMStorageAccountKey -StorageAccountName $StorageAccountName -ResourceGroupName $rgname
# the script will be using primary key
$key = $fullkeys[0].Value
## OLD (pre v1.4.0)
## $key = $fullkeys.Key1 # this differs to the Get-AzureStorageAccountKey cmdlet's output!
# getting storage account content
$context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $key
# find my container
Get-AzureStorageContainer -Context $context -Name $container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment