ARM模板 - 部署customScriptForLinux

时间:2016-02-27 08:13:57

标签: azure azure-resource-manager

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

我想通过存储在Github Public repo中的脚本来配置未分区/未格式化的硬盘。

但是这个模板总是失败,错误如下。错误说cannot launch the script,但这是真的吗? github repo 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"
                }
            }
        }
    ]
}

1 个答案:

答案 0 :(得分:1)

对于CentOS,您需要明确调用sh,尝试更改:

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

为:

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