1

I am trying to enable encryption in azure storage during its creation time through ARM. This is the simple storage resource I have.

{
  "$schema": "https://schema.management.azure.com/schemas/2016-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
  "storageAccountName": {
  "type": "String"
},
  "storageAccountType": {
  "type": "string",
  "defaultValue": "Standard_LRS",
  }
},
  "variables": {
  "defaultApiVersion": "2016-01-01"
 },
"resources": [
{
  "type": "Microsoft.Storage/storageAccounts",
  "name": "[parameters('StorageAccountName')]",
  "apiVersion": "[variables('defaultApiVersion')]",
  "location": "[resourceGroup().location]",
  "sku": {
    "name": "[parameters('storageAccountType')]"
  },
  "properties": {
    "properties": {
      "encryption": {
            "keySource": "Microsoft.Storage",
            "services": {
                "blob": {
                    "enabled": true
                }
            }
        }
    }
  }
}
]
}

Which giving me following error

New-AzureRmResourceGroupDeployment : 8:21:59 AM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'Template schema 'https://schema.management.azure.com/schemas/2016-01-01/deploymentTemplate.json#' is not supported. Supported versions are '2014-04-01-preview,2015-01-01'.

Then I change the schema url to https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#

then got New-AzureRmResourceGroupDeployment : 8:26:40 AM - Error: Code=InvalidTemplateDeployment; Message=The template deployment 'myencryptedstorage' is not valid according to the validation procedure.

Anyone know whats is the right way to do this ?

roy
  • 6,344
  • 24
  • 92
  • 174
  • which way did you use to access azure storage? CLI, powershell or just rest api? – qin Oct 01 '16 at 06:28
  • Did you reference the right schema, ie. v 2016-01-01? azure-resource-manager-schemas/schemas/2016-01-01/Microsoft.Storage.json And what error message did you get? – Russell Young Oct 01 '16 at 08:27
  • @RussellYoung I have updated my question. – roy Oct 01 '16 at 12:28
  • [Avoid using a parameter or variable for the API version for a resource type. Resource properties and values can vary by version number. IntelliSense in a code editor cannot determine the correct schema when the API version is set to a parameter or variable. Instead, hard-code the API version in the template.](https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-template-best-practices#parameters) – oatsoda Jul 21 '17 at 08:56

2 Answers2

1

I have copied your json file to Visual Studio. It give me the following error message: enter image description here

I think this may be your issue.

I have tested use New-AzureRmResourceGroupDeployment to create Azure storage with encryption enabled. The following is my source code:

PowerShell Command:

New-AzureRmResourceGroupDeployment -ResourceGroupName jarg -TemplateFile E:\createstoragearm.json - TemplateParameterFile E:\parameter.json

createstoragearm.json

{

  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",

  "contentVersion": "1.0.0.0",

  "parameters": {
    "storageAccountName": {
      "type": "string"
    },
    "storageAccountType": {

      "type": "string",

      "defaultValue": "Standard_LRS",

      "allowedValues": [

        "Standard_LRS",

        "Standard_GRS",

        "Standard_ZRS",

        "Premium_LRS"

      ],

      "metadata": {

        "description": "Storage Account type"

      }

    }

  },

  "variables": {

    "storageAccountName": "[parameters('storageAccountName')]"

  },

  "resources": [

    {

      "type": "Microsoft.Storage/storageAccounts",

      "name": "[variables('storageAccountName')]",

      "apiVersion": "2016-01-01",

      "location": "[resourceGroup().location]",

      "sku": {

        "name": "[parameters('storageAccountType')]"

      },

      "kind": "Storage",

      "properties": {
        "encryption": {
          "services": {
            "blob": {
              "enabled": true
            }
          },
          "keySource": "Microsoft.Storage"
        }
      }

    }

  ],

  "outputs": {

    "storageAccountName": {

      "type": "string",

      "value": "[variables('storageAccountName')]"

    }


  }

}

parameter.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "StorageAccountName": {
      "value": "jaarmtest1"
    },

    "StorageAccountType": {
      "value": "Standard_LRS"
    }

  }
}

The Result

enter image description here

Jambor - MSFT
  • 3,175
  • 1
  • 13
  • 16
1

As far as the invalid template error goes I notice you do have properties listed twice:

"properties": { "properties": {

You can reference this link to find the valid schema: https://msdn.microsoft.com/en-us/library/azure/mt163564.aspx

Andrew W
  • 123
  • 2
  • 7