Azure 手臂模板验证
Azure arm template validation
我的 ARM 模板代码失败并出现以下验证错误。
域加入应该等到自定义脚本扩展完成。请参阅下面的代码。我无法理解资源和子资源依赖项的工作方式以及如何命名资源。不胜感激,如果你能引导我到一篇文章来学习。
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/cse')]",
"apiVersion": "2017-03-30",
"location": "[variables('varlocation')]",
"dependsOn": [
"[concat(variables('varnodeNamePrefix'),copyindex(1))]"
],
"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":"[variables('varvmCount')]"
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/joindomain')]",
"location": "[resourceGroup().location]",
"dependsOn": ["[concat(variables('varnodeNamePrefix'),copyindex(1),'/cse')]"
],
"properties": {
"publisher": "Microsoft.Compute",
"type": "JsonADDomainExtension",
"typeHandlerVersion": "1.3",
"autoUpgradeMinorVersion": true,
"settings": {
"Name": "[variables('vardomainToJoin')]",
"User": "[concat(variables('vardomainToJoin'), '\', variables('vardomainUsername'))]",
"Restart": "true",
"Options": "[variables('vardomainJoinOptions')]"
},
"protectedSettings": {
"Password": "[variables('vardomainPassword')]"
}
},
"copy": {
"name": "joindomain",
"count":"[variables('varvmCount')]"
}
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(基本上和上面写的一样)
我的 ARM 模板代码失败并出现以下验证错误。
域加入应该等到自定义脚本扩展完成。请参阅下面的代码。我无法理解资源和子资源依赖项的工作方式以及如何命名资源。不胜感激,如果你能引导我到一篇文章来学习。
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/cse')]",
"apiVersion": "2017-03-30",
"location": "[variables('varlocation')]",
"dependsOn": [
"[concat(variables('varnodeNamePrefix'),copyindex(1))]"
],
"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":"[variables('varvmCount')]"
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/joindomain')]",
"location": "[resourceGroup().location]",
"dependsOn": ["[concat(variables('varnodeNamePrefix'),copyindex(1),'/cse')]"
],
"properties": {
"publisher": "Microsoft.Compute",
"type": "JsonADDomainExtension",
"typeHandlerVersion": "1.3",
"autoUpgradeMinorVersion": true,
"settings": {
"Name": "[variables('vardomainToJoin')]",
"User": "[concat(variables('vardomainToJoin'), '\', variables('vardomainUsername'))]",
"Restart": "true",
"Options": "[variables('vardomainJoinOptions')]"
},
"protectedSettings": {
"Password": "[variables('vardomainPassword')]"
}
},
"copy": {
"name": "joindomain",
"count":"[variables('varvmCount')]"
}
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(基本上和上面写的一样)