域连接应该等到自定义脚本扩展完成。请注意以下代码。我无法理解资源和子资源依赖关系如何工作以及如何命名资源。感谢您是否可以引导我学习一篇文章。
{
"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(基本上与上面写的相同)