Azure 中的自定义模板部署 - 架构错误

Custom template deployment in Azure - Schema Error

我正在尝试在 Azure 的自定义部署中上传存储帐户“template.json”文件。 link 我指的是部署模板是 - https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/quickstart-create-templates-use-the-portal.

但我收到以下架构错误:

"Unable to load schema from 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json'. No schema request service available"

我尝试过使用不同的版本,例如“2019-04-01”和“2021-02-01”。仍然不起作用。 有人可以帮我正确部署这个模板吗?

我的template.json文件如下:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "storageAccounts_name": {
        "defaultValue": "NameOfStorageAccount",
        "type": "String"
    }
},
"variables": {},
"resources": [
    {
        "type": "Microsoft.Storage/storageAccounts",
        "apiVersion": "2021-04-01",
        "name": "[parameters('storageAccounts_name')]",
        "location": "eastus",
        "tags": {
            "Application": "CA",
            "Environment": "Test"
        },
        "sku": {
            "name": "Standard_RAGRS",
            "tier": "Standard"
        },
        "kind": "StorageV2",
        "properties": {
            "isHnsEnabled": true,
            "networkAcls": {
                "bypass": "AzureServices",
                "virtualNetworkRules": [],
                "ipRules": [],
                "defaultAction": "Allow"
            },
            "supportsHttpsTrafficOnly": true,
            "encryption": {
                "services": {
                    "file": {
                        "keyType": "Account",
                        "enabled": true
                    },
                    "blob": {
                        "keyType": "Account",
                        "enabled": true
                    }
                },
                "keySource": "Microsoft.Storage"
            },
            "accessTier": "Hot"
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "sku": {
            "name": "Standard_RAGRS",
            "tier": "Standard"
        },
        "properties": {
            "cors": {
                "corsRules": []
            },
            "deleteRetentionPolicy": {
                "enabled": false
            }
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/fileServices",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "sku": {
            "name": "Standard_RAGRS",
            "tier": "Standard"
        },
        "properties": {
            "protocolSettings": {
                "smb": {}
            },
            "cors": {
                "corsRules": []
            }
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/queueServices",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "cors": {
                "corsRules": []
            }
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/tableServices",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "cors": {
                "corsRules": []
            }
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default/archive')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]",
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "defaultEncryptionScope": "$account-encryption-key",
            "denyEncryptionScopeOverride": false,
            "publicAccess": "None"
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default/intermediate')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]",
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "defaultEncryptionScope": "$account-encryption-key",
            "denyEncryptionScopeOverride": false,
            "publicAccess": "None"
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default/processed')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]",
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "defaultEncryptionScope": "$account-encryption-key",
            "denyEncryptionScopeOverride": false,
            "publicAccess": "None"
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default/propectstest')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]",
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "defaultEncryptionScope": "$account-encryption-key",
            "denyEncryptionScopeOverride": false,
            "publicAccess": "None"
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default/staging')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]",
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "defaultEncryptionScope": "$account-encryption-key",
            "denyEncryptionScopeOverride": false,
            "publicAccess": "None"
        }
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
        "apiVersion": "2021-04-01",
        "name": "[concat(parameters('storageAccounts_name'), '/default/test-sandbox')]",
        "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]",
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]"
        ],
        "properties": {
            "defaultEncryptionScope": "$account-encryption-key",
            "denyEncryptionScopeOverride": false,
            "publicAccess": "None"
        }
    }
]

}

  1. 您正在部署具有分层命名空间的存储帐户 (isHnsEnabled=true)。这些帐户 (docs) 不支持加密范围。要使您的模板正常工作,您必须删除容器上的 defaultEncryptionScopedenyEncryptionScopeOverride 属性。

  2. 此外,删除 Microsoft.Storage/storageAccounts/fileServices 资源上的空 protocolSettingscors 属性。

Final template.json,对我来说部署得很好,看起来像这样:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageAccounts_name": {
      "defaultValue": "NameOfStorageAccount",
      "type": "String"
    }
  },
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2021-04-01",
      "name": "[parameters('storageAccounts_name')]",
      "location": "eastus",
      "tags": {
        "Application": "CA",
        "Environment": "Test"
      },
      "sku": {
        "name": "Standard_RAGRS",
        "tier": "Standard"
      },
      "kind": "StorageV2",
      "properties": {
        "isHnsEnabled": true,
        "networkAcls": {
          "bypass": "AzureServices",
          "virtualNetworkRules": [],
          "ipRules": [],
          "defaultAction": "Allow"
        },
        "supportsHttpsTrafficOnly": true,
        "encryption": {
          "services": {
            "file": {
              "keyType": "Account",
              "enabled": true
            },
            "blob": {
              "keyType": "Account",
              "enabled": true
            }
          },
          "keySource": "Microsoft.Storage"
        },
        "accessTier": "Hot"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "sku": {
        "name": "Standard_RAGRS",
        "tier": "Standard"
      },
      "properties": {
        "cors": { "corsRules": [] },
        "deleteRetentionPolicy": { "enabled": false }
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/fileServices",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "sku": {
        "name": "Standard_RAGRS",
        "tier": "Standard"
      },
      "properties": {
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/queueServices",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": { "cors": { "corsRules": [] } }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/tableServices",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": { "cors": { "corsRules": [] } }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default/archive')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": {
        "publicAccess": "None"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default/intermediate')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": {
        "publicAccess": "None"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default/processed')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": {
        "publicAccess": "None"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default/propectstest')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": {
        "publicAccess": "None"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default/staging')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": {
        "publicAccess": "None"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('storageAccounts_name'), '/default/test-sandbox')]",
      "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" ],
      "properties": {
        "publicAccess": "None"
      }
    }
  ]
}