A nasty breaking change has slipped into version 1.1.0 of AzureRM.Storage which coincide with the release v1.4.0 of AzureRM module. If you use the return object of the Get-AzureRmStorageAccountKey command you are impacted.

This is because the object that was coming out of Get-AzureRmStorageAccountKey was Microsoft.Azure.Management.Storage.Models.StorageAccountKeys and it is now a list of Microsoft.Azure.Management.Storage.Models.StorageAccountKey objects.

The old output

In your code you probably have a code like this... You get the storage account keys to then create a storage context.

$keys = Get-AzureRmStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName 
$context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $keys.Key1

Before, each key was stored as a string in Key1 and Key2 properties.

  • $keys.Key1
  • $keys.Key2

The new output

The new type is a List<Microsoft.Azure.Management.Storage.Models.StorageAccountKey>. Each object in the list has 3 members: KeyName, Value & Permissions.

New output object of Get-AzureRmStorageAccountKey

To get the keys you now need to do this:

  • $keys[0].Value
  • $keys[1].Value

Anothe, simplier way to obtain an AzureStorageContext

If you need to get the keys only to create an Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext object you can use the .Context member of a Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount object like this:

$storage = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
$storage.Context 

Another way to obtain a storage account context

Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount.Context

Conclusion

This is a breaking change and should not have ended up in a minor version upgrade like it did. Microsoft need to be more cautious and build checks to prevent this from happening again. This will impact a LOT of scripts out there.