ARM 模板 - 部署一个 customScriptForLinux

ARM template - deploy a customScriptForLinux

在 Azure 中,我在 resource group 下有一个 centOS Linux VM 运行。

我想通过存储在 Github Public 存储库中的脚本来配置 unpartitioned/unformated 硬盘。

但是此模板总是失败并出现以下错误。错误说cannot launch the script,但真的是这个原因吗? github 存储库 URL 可以公开查看。

在哪里可以找到更多调试信息以及此部署失败的原因?

{"status":"Failed","error":{"code":"ResourceDeploymentFailure","message":"The resource operation completed with terminal provisioning state 'Failed'.","details":[{"code":"VMExtensionProvisioningError","message":"VM has reported a failure when processing extension 'azureVmUtils'. Error message: \"Lanch script failed: [Errno 8] Exec format error\"."}]}

ARM 模板文件

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "variables": {
        "location": "[resourceGroup().location]",
        "vmName": "az-prx-sc-we-vm-app-01",
        "apiVersion": "2015-06-15",
        "scriptUrl": "https://raw.githubusercontent.com/Xixiao007/Azure-extension-scripts/master/vm-disk-utils-centos-0.1.sh"
    },
    "resources": [
        {
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(variables('vmName'), '/azureVmUtils')]",
            "apiVersion": "[variables('apiVersion')]",
            "location": "[variables('location')]",
            "properties": {
                "publisher": "Microsoft.OSTCExtensions",
                "type": "CustomScriptForLinux",
                "typeHandlerVersion": "1.4",
                "settings": {
                    "fileUris": [
                        "[variables('scriptUrl')]"
                    ],
                    "commandToExecute": "./vm-disk-utils-centos-0.1.sh"
                }
            }
        }
    ]
}

对于 CentOS,您需要显式调用 sh,尝试更改:

"commandToExecute": "./vm-disk-utils-centos-0.1.sh" 

至:

"commandToExecute": "sh vm-disk-utils-centos-0.1.sh"