我已经使用 ARM 模板创建了一个 Azure VM,并希望在部署 VM 后在同一 VM 上运行 2 个 VM 脚本扩展。
如何使用 ARM 模板实现?
{
"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-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.1",
"settings": {
"fileUris": ["[variables('installScript1')]"]
},
"protectedSettings":{
"commandToExecute": "[concat('bash config1.sh', ' ', parameters('key1'))]"
}
}
},
更新:-
目前我正在运行 config.sh 和 config1.sh,扩展名与下面相同。但它一个接一个地运行。我希望使用扩展同时启动 config.sh 和 config1.sh。
{
"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.1",
"settings": {
"fileUris": ["[variables('installScript1')]"]
},
"protectedSettings":{
"commandToExecute": "[concat('bash config1.sh', ' ', parameters('key1'), ' ', '&&', ' ', 'bash config.sh', ' ', parameters('key'))]"
}
}
},