代码之家  ›  专栏  ›  技术社区  ›  Kamsiinov

Azure自定义扩展失败,错误消息为:“已完成执行命令”

  •  0
  • Kamsiinov  · 技术社区  · 7 年前

    我开始在Azure中测试自定义扩展,并从非常简单的json和ps1脚本开始。我的json文件如下所示:

    {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "vmName": {
            "type": "string"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(parameters('vmName'),'/RunDateTimeScript')]",
            "apiVersion": "2015-06-15",
            "location": "[resourceGroup().location]",
            "properties": {
                "publisher": "Microsoft.Compute",
                "type": "CustomScriptExtension",
                "typeHandlerVersion": "1.8",
                "autoUpgradeMinorVersion": true,
                "settings": {
                    "fileUris": [
                        "https://github.com/username/repo/blob/master/writedatetime.ps1"
                    ],
                    "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File writedatetime.ps1"
                }
            }
        }
    ]
    }
    

    我的powershell脚本是一个单行程序:

    (Get-Date).DateTime | Out-File "C:\Testing.txt" -Append
    

    但是,当我运行通常的powershell部署命令时:

    New-AzureRmResourceGroupDeployment -ResourceGroupName MyResources -TemplateFile .\extensionexample.json -vmName MyVmName01
    

    结果我失败了,并且:

    “消息”:“VM在处理扩展时报告了故障 “RunDateTimeScript”。错误消息:\“已完成执行命令\”

    1 回复  |  直到 7 年前
        1
  •  1
  •   Kamsiinov    7 年前

    这个问题相当愚蠢。我为github使用了错误的url,因为它应该是原始url,而不是模板中的url。即 https://raw.githubusercontent.com/username/repo/master/script.ps1