如何在同一模板中为HDI集群的VM扩展脚本中添加dependsOn



我想做以下

  1. 创建HDI集群(资源组1(和2个VM(资源组2(并行
  2. 部署HDI和VM1后在VM1中运行扩展脚本
  3. 部署VM1和VM2后在VM2中运行扩展脚本

我收到错误,如下

错误:部署模板验证失败:'资源中未定义"Microsoft.Resources/deployments/clusterTemplate"模板。请参阅https://aka.ms/arm-template供使用详细信息。

如何解决此问题?

{
"apiVersion": "[variables('resourceDeploymentApiVersion')]",
"name":"[variables('clusterTemplateName')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('clusterResourceGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('clusterTemplateURL')]"
},
"parameters": {
"clusterName": { "value": "[parameters('clusterName')]" 
}
}
},          
{
"apiVersion": "[variables('resourceDeploymentApiVersion')]",
"name": "[variables('vmTemplateName')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('vmResourceGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('vmTemplateURL')]"
},
"parameters": {
"appid": { "value": "[parameters('appid')]" }
}
}             
},
{
"apiVersion": "[variables('resourceDeploymentApiVersion')]",
"name": "[variables('vmTemplateName1')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('vmResourceGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('vmTemplateURL1')]"
},
"parameters": {
"appid": { "value": "[parameters('appid')]" }
}
}             
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat('vmName','/install-script')]",
"apiVersion": "[variables('computeApiVersion')]",
"location": "[variables('location')]",  
"dependsOn": [
"[resourceId('Microsoft.Resources/deployments', variables('clusterTemplateName'))]",
"[resourceId('Microsoft.Resources/deployments', variables('vmTemplateName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": ["[variables('installScript')]"]
},
"protectedSettings":{
"commandToExecute": "[concat('bash init.sh', ' ', parameters('appId'))]"
}
}
},{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat('vmName','/install-script')]",
"apiVersion": "[variables('computeApiVersion')]",
"location": "[variables('location')]",  
"dependsOn": [
"[resourceId('Microsoft.Resources/deployments', variables('vmTemplateName'))]",
"[resourceId('Microsoft.Resources/deployments', variables('vmTemplateName1'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": ["[variables('installScript')]"]
},
"protectedSettings":{
"commandToExecute": "[concat('bash init.sh', ' ', parameters('appId'))]"
}
}
}

我可以通过在resourceId 中使用集群资源组名称来解决问题

之前:-

"[resourceId('Microsoft.Resources/deployments', variables('clusterTemplateName'))]",

之后:-

"dependsOn": [
"[resourceId(parameters('clusterResourceGroupName'), 'Microsoft.Resources/deployments', variables('clusterTemplateName'))]",

相关内容

  • 没有找到相关文章

最新更新