Friday, January 27, 2017

Solving "The storage account named XXXXX already exists under the subscription" when deploying Azure Resource Group templates

I've recently run into a problem where I've been unable to deploy multiple resource groups for my applications that contain Storage Accounts. When executing the Resource Group template deployment, I get the following error:

"The storage account named XXXXX already exists under the subscription"

The underlaying cause seems to be that Microsoft fucked up backward compatibility on their API in resource group templates. Thanks to this blog post, I was able to get back up and running. The gist of the article, repeated here for posterity, is that you have to update to the latest (as of this writing) API version of 2016-01-01. For example:

{
    “$schema”“https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#”,
    “contentVersion”“1.0.0.0”,
    “resources”: [
      {
        “name”“dnntest20160705”,
        “type”“Microsoft.Storage/storageAccounts”,
        “location”“[resourceGroup().location]”,
        “apiVersion”“2016-01-01”,
        “dependsOn”: [ ],
        “tags”: {
          “displayName”“MyStorageAccount”
        },
        “sku”: {
          “name”“Standard_LRS”
        },
        “kind”“Storage”
      }
    ]
}