Intro

There are two ways to manage resources in Azure: Classic and Resource Manager. Resource Manager is the recommended way now, you can read more about resource manager at Azure Resource Manager overview. Microsoft will enable Resource Manager for every service that is important for future solutions, but until the support is consistent, you need to know the current status for each service. For example it is possible to use Azure Storage cmdlets in a resource manager context, you can mix them easily.

Prerequisites

Refer to previous posts to get started with Azure Storage Queue Service.

Code

Run the following command:

PS C:\WINDOWS\system32> Get-AzureRmStorageAccount


ResourceGroupName   : default
StorageAccountName  : default748347
Id                  : /subscriptions/<GUID>/resourceGroups/default/providers/Microsoft.St
                      orage/storageAccounts/default748347
Location            : australiaeast
Sku                 : Microsoft.Azure.Management.Storage.Models.Sku
Kind                : Storage
Encryption          :
AccessTier          :
CreationTime        : 9/10/2016 12:34:34 PM
CustomDomain        :
LastGeoFailoverTime :
PrimaryEndpoints    : Microsoft.Azure.Management.Storage.Models.Endpoints
PrimaryLocation     : australiaeast
ProvisioningState   : Succeeded
SecondaryEndpoints  :
SecondaryLocation   : australiasoutheast
StatusOfPrimary     : Available
StatusOfSecondary   : Available
Tags                : {}
Context             : Microsoft.WindowsAzure.Commands.Common.Storage.LazyAzureStorageContext

PS C:\WINDOWS\system32> Get-AzureRmContext

Environment           : AzureCloud
Account               : dummy@outlook.com
TenantId              : <GUID>
SubscriptionId        : <GUID>
SubscriptionName      : Visual Studio Enterprise
CurrentStorageAccount : default748347

We have only one storage account and it is set as default.

Create another storage account in the same resource group:

PS C:\WINDOWS\system32> New-AzureRmStorageAccount -ResourceGroupName Default -AccountName secondary748347 -Location "Aus
tralia East" -Type "Standard_GRS"

ResourceGroupName   : default
StorageAccountName  : secondary748347
Id                  : /subscriptions/<GUID>/resourceGroups/default/providers/Microsoft.St
                      orage/storageAccounts/secondary748347
Location            : australiaeast
Sku                 : Microsoft.Azure.Management.Storage.Models.Sku
Kind                : Storage
Encryption          :
AccessTier          :
CreationTime        : 9/11/2016 3:46:04 AM
CustomDomain        :
LastGeoFailoverTime :
PrimaryEndpoints    : Microsoft.Azure.Management.Storage.Models.Endpoints
PrimaryLocation     : australiaeast
ProvisioningState   : Succeeded
SecondaryEndpoints  :
SecondaryLocation   : australiasoutheast
StatusOfPrimary     : Available
StatusOfSecondary   : Available
Tags                : {}
Context             : Microsoft.WindowsAzure.Commands.Common.Storage.LazyAzureStorageContext

All Azure Storage cmdlets use a default storage account, so calls to Get-AzureStorageQueue or Get-AzureStorageBlob will list entities from CurrentStorageAccount. If it is required to use a secondary storage account, a storage account context will be used. It is possible to create a storage account context like this:

PS C:\WINDOWS\system32> $ctx = New-AzureStorageContext -StorageAccountName secondary748347 -StorageAccountKey (Get-AzureRmStorageAccountKey -ResourceGroupName Default -Name secondary748347)[0].Value

Now you can use it like this:

PS C:\WINDOWS\system32> Get-AzureStorageQueue -Context $ctx

This command shows all Azure Storage queues in the secondary storage account.

Summary

Resource manager is an awesome addition to all other features of Azure. Unfortunately it lacks documentation and working samples. In any case, I belive it will be fixed in the near future.


;