Azure Arm模板验证

时间:2019-02-12 10:03:26

标签: azure azure-resource-manager arm-template azure-template

我的ARM模板代码因以下验证错误而失败。 enter image description here

域联接应等待,直到自定义脚本扩展完成。请参见下面的代码。我无法理解资源和子资源依赖项的工作方式以及如何命名资源。谢谢您能引导我学习文章。

child: nestedScrollView(
controller: // add a `ScrollController` here
),

1 个答案:

答案 0 :(得分:1)

resourceId错误,应该是这样:

"[resourceId('Microsoft.Compute/virtualMachines/extensions',concat(variables('varnodeNamePrefix'),copyindex(1)),'extensions')]"

或简单地:

concat(variables('varnodeNamePrefix'),copyindex(1),'/extensions')

该错误告诉您-您在此处有3个细分:Microsoft.Compute/virtualMachines/extensions,但之后只有1个细分:concat(variables('varnodeNamePrefix'),copyindex(1),'/extensions'))

但是它应该有2个细分,因为它试图这样做:

Microsoft.Compute/virtualMachines/{segment1}/extensions/{segment2}

工作副本:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {
        "varnodeNamePrefix": "testing"
    },
    "resources": [
        {
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/cse')]",
            "apiVersion": "2017-03-30",
            "location": "[resourceGroup().location]",
            "properties": {
                "publisher": "Microsoft.Compute",
                "type": "CustomScriptExtension",
                "typeHandlerVersion": "1.8",
                "autoUpgradeMinorVersion": true,
                "settings": {
                    "fileUris": [
                        "https://XXXXXXXXXXX.blob.core.windows.net/powershelscripts/sqlcluster/InstallAdditionalModules.ps1"
                    ]
                },
                "protectedSettings": {
                    "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted ./sqlcluster/InstallAdditionalModules.ps1",
                    "storageAccountName": "sdfsdfsdfsdf",
                    "storageAccountKey": "sdsdfsdf/BH9C+fdgdfgdfgdfg+fgdfgdfg=="
                }
            },
            "copy": {
                "name": "WinFeatures",
                "count": 3
            }
        },
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/joindomain')]",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[resourceId('Microsoft.Compute/virtualMachines/extensions',concat(variables('varnodeNamePrefix'),copyindex(1)),'cse')]"
            ],
            "properties": {
                "publisher": "Microsoft.Compute",
                "type": "JsonADDomainExtension",
                "typeHandlerVersion": "1.3",
                "autoUpgradeMinorVersion": true,
                "settings": {
                    "Name": "yyy.zzz",
                    "User": "[concat('xxx', '\\', 'xxx')]",
                    "Restart": "true"
                },
                "protectedSettings": {
                    "Password": "xxx"
                }
            },
            "copy": {
                "name": "joindomain",
                "count": 3
            }
        }
    ]
}

完整的工作示例:https://paste.ee/p/XlBHY(基本上与上面写的相同)