Search code examples
azureazure-storageazure-resource-managerazure-policy

"InvalidTemplate"; Message Deployment template parse failed:


Getting the below error while deploying the template Error code InvalidTemplate Message Deployment template parse failed: 'Error converting value "Standard_LRS" to type 'Microsoft.WindowsAzure.ResourceStack.Common.Core.Definitions.Resources.ResourceSku'. Path ''.'.

{
              "$schema": "http://schema.management.azure.com/schemas/,2019-08-01/deploymentTemplate.json#",
              "contentVersion": "1.0.0.0",
              "parameters": {
                "locationName": {
                  "type": "string"
                },
                "StorageName": {
                  "type": "string"
                },
                "StorageKind": {
                  "type": "string"
                },
                "skuname": {
                  "type": "string"
                },
                "skutier": {
                  "type": "string"
                }
              },
              "variables": {},
              "resources": [
                {
                  "name": "[parameters('StorageName')]",
                  "type": "Microsoft.Storage/storageAccounts",
                  "apiVersion": "2021-02-01",
                  "kind": "[parameters('StorageKind')]",
                  "sku": {
                    "name": "[parameters('skuname')]",
                    "tier": "[parameters('skutier')]"
                  },
                  "location": "[parameters('locationname')]",
                  "properties": {
                    "bypass": "None",
                    "ipRules": [
                      {
                        "value": "205.145.64.0",
                        "action": "Allow"
                      },
                      {
                        "value": "205.145.64.1",
                        "action": "Allow"
                      }
                    ],
                    "defaultAction": "Allow"
                  }
                }
              ]
            }

Edit

Able to deploy the template but not able to add the firewall rules.


Solution

  • In your template, you lack adding networkAcls object. The ipRules should be included in networkAcls object and the defaultAction should be set to Deny.

    test.json

    {
                  "$schema": "http://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
                  "contentVersion": "1.0.0.0",
                  "parameters": {
                    "locationName": {
                      "type": "string"
                    },
                    "StorageName": {
                      "type": "string"
                    },
                    "StorageKind": {
                      "type": "string"
                    },
                    "skuname": {
                      "type": "string"
                    },
                    "skutier": {
                      "type": "string"
                    }
                  },
                  "variables": {},
                  "resources": [
                    {
                      "name": "[parameters('StorageName')]",
                      "type": "Microsoft.Storage/storageAccounts",
                      "apiVersion": "2021-02-01",
                      "kind": "[parameters('StorageKind')]",
                      "sku": {
                        "name": "[parameters('skuname')]",
                        "tier": "[parameters('skutier')]"
                      },
                      "location": "[parameters('locationname')]",
                      "properties": {
                        "networkAcls": {
                            "bypass": "None",
                            "ipRules": [
                              {
                                "value": "205.145.64.0",
                                "action": "Allow"
                              },
                              {
                                "value": "205.145.64.1",
                                "action": "Allow"
                              }
                            ],
                            "defaultAction": "Deny"
                            }
    
                      }
                    }
                  ]
                }
    

    test.parameters.json

    {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "locationName": {
                "value": "eastus" 
            },
            "StorageName": {
                "value": "xxxxxx" 
            },
            "StorageKind": {
                "value": "StorageV2" 
            },
            "skuname": {
                "value": "Standard_LRS" 
            },
            "skutier": {
                "value": "Standard" 
            }
        }
    }