我想在创建VM之后运行第一个扩展脚本。然后,在部署群集之后,我想在具有设置时间戳记的同一台VM上运行第二个扩展脚本。但是我无法运行第二个脚本。它显示如下错误
“ Linux”操作系统类型不支持每个处理程序多个VMExtensions
d
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/install-script')]",
"apiVersion": "[variables('computeApiVersion')]",
"location": "[variables('location')]",
"dependsOn": [
"[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 config.sh', ' ', parameters('key'))]"
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/install-script1')]",
"apiVersion": "[variables('computeApiVersion')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId(parameters('clusterResourceGroupName'), '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('installScript1')]"],
"timestamp": "123456789"
},
"protectedSettings":{
"commandToExecute": "[concat('bash config1.sh', ' ', parameters('key1'))]"
}
}
},
更新:-
我正在使用以下方法部署群集和VM。我仍然遇到相同的错误。我已经添加了 forceUpdatetag ,我需要对此方法进行哪些修改才能使其正常工作?
{
"apiVersion": "[variables('resourceDeploymentApiVersion')]",
"name": "[variables('clusterTemplateName')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('clusterResourceGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('clusterTemplateURL')]"
},
"parameters": {},
}
},
{
"apiVersion": "[variables('resourceDeploymentApiVersion')]",
"name": "[variables('vmTemplateName')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('vmGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('vmTemplateURL')]"
},
"parameters": {},
}
}
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/install-script')]",
"apiVersion": "[variables('computeApiVersion')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/deployments', variables('vmTemplateName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"forceUpdateTag": "v.1.0",
"settings": {
"fileUris": ["[variables('installScript')]"]
},
"protectedSettings":{
"commandToExecute": "[concat('bash config.sh', ' ', parameters('key'))]"
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/install-script1')]",
"apiVersion": "[variables('computeApiVersion')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId(parameters('clusterResourceGroupName'), 'Microsoft.Resources/deployments', variables('clusterTemplateName'))]",
"[resourceId('Microsoft.Resources/deployments', variables('vmTemplateName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"forceUpdateTag": "v.1.1",
"settings": {
"fileUris": ["[variables('installScript1')]"]
},
"protectedSettings":{
"commandToExecute": "[concat('bash config1.sh', ' ', parameters('key1'))]"
}
}
},
答案 0 :(得分:1)
您可以对嵌套部署执行此操作。因此,您需要创建一个具有脚本扩展名的虚拟机并创建一个嵌套部署。该嵌套部署需要依赖于扩展才能完成。嵌套的部署将只是另一个资源(Microsoft.Compute / virtualMachines /扩展),并且它必须具有与先前脚本扩展名相同的名称,并且必须具有不同的forceUpdateTag
。这样就可以了。
此解决方法是必需的,因为VM只能具有每个扩展类型的1个副本。这样,您可以使用新值更新扩展名,并强制其使用forceUpdateTag
重新运行。
工作示例:
https://paste.ee/p/4mOiI-仅具有脚本扩展名的嵌套模板
https://paste.ee/p/nG7XV-父模板