手臂模板PowerShell自定义脚本

时间:2019-01-31 11:25:33

标签: azure azure-resource-manager

作为我的ARM模板的一部分,我需要执行PowerShell脚本来安装故障转移群集窗口功能。但是,脚本至少运行10分钟,然后失败,并出现以下错误。

  

new-azResourceGroupDeployment:11:18:03-资源   Microsoft.Compute /虚拟机器/扩展   'DI-ukwest-DB1 / extensions'失败,并显示消息'{“ status”:   “失败”,“错误”:{       “ code”:“ ResourceDeploymentFailure”,       “ message”:“资源操作已完成,终端供应状态为“失败”。”,       “细节”: [         {           “ code”:“ VMExtensionProvisioningError”,           “消息”:“ VM报告扩展扩展名时失败。错误消息:”“无法全部下载   指定的文件。正在退出。错误消息:远程服务器返回了   错误:(400)错误的请求。\“。         }       ]}}'

我的脚本是

{
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "name": "[concat(variables('varnodeNamePrefix'),copyindex(1),'/extensions')]",
      "apiVersion": "2017-03-30",
      "location": "[variables('varlocation')]",
      "dependsOn": [
        "[concat(variables('varnodeNamePrefix'),copyindex(1))]"
      ],
      "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.8",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "fileUris": [
            "https://XXXXXarmtemplets.file.core.windows.net/powershellscripts/sqlcluster/InstallWindowsFeaturs.ps1"
          ]
        },
        "protectedSettings": {
          "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -InstallWindowsFeaturs.ps1",
          "storageAccountName": "XXXXXarmtemplets",
          "storageAccountKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        }
      },
      "copy": {
        "name": "WinFeatures",
        "count":"[variables('varvmCount')]"
      }
    }

谢谢

1 个答案:

答案 0 :(得分:0)

该错误非常可靠-扩展程序无法下载ps1文件。我注意到您有“ file” .core.windows.net而不是“ blob”,这是常见的用例-所以一件事要检查...

此外,您可以登录到VM并检查日志,请参阅:

https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows#troubleshoot-and-support