Compartir a través de


The recurrent error of non-current, current storage accounts

I was writing some sample code in which the OS disk would be named explicitly (as opposed to letting Azure assign the name to the disk). In addition, I was creating a data disk using the same approach for its name. The goal was to create the VM while ensuring each disk was in a different storage account.

I tried running the sample, but I would get the following error:

“CurrentStorageAccountName is not accessible. Ensure the current storage account is accessible and in the same location or affinity group as your cloud service.”

Since I was not working with my default storage account, but rather specifying where the disks were to be created, I didn’t pay attention to the current storage account. Instead, I Bing’ed the error message and found Ross Bradbrook’s blog entry: New-AzureVM: CurrentStorageAccount is not Accessible.

It basically states that if you are creating a VM, and its cloud service already exists, you can’t specify a location or affinity group, or else you’ll get the error.

I completely forgot about that detail (I curse you, PowerShell tab completion!) and provided values to both. I thought “that’s easy enough”, removed the affinity group parameter and retried.

To my surprise, the command returned the same error:

image

Since I was out of ideas, I decided to turn on verbose debugging by setting the $DebugPreference variable to “Continue”.

When I retried the attempt, I got the following (partial) result. Note the white boxes highlighting the error:

image

The portalvhdsg87rhb7rnqrbl storage account was not found. I remembered that before starting to write the code sample, I completely cleaned up my Azure subscription, and had removed the account.

As a test, I re-created the storage account using the same name, retried the operation… and voilà! Everything worked like a charm.

I could have as well selected one of the other storage accounts as my current storage account and it would have worked also.

It is interesting, though, that there is a requirement that a valid current storage account exist, even if you are not using that storage account for the creation of the VM.