Azure ARM DSC 规模集部署 - 找不到脚本

Azure ARM DSC scale set deployment - cannot locate script

我正在尝试使用 ARM 模板和所需状态配置 (DSC) 将虚拟机规模集部署到 Azure。我已经创建了 DSC 配置并在它正在运行的单独 VM 上对其进行了验证。在 ARM 模板中,我对 DSC 扩展有以下定义:

{
    "name": "Microsoft.Powershell.DSC",
    "properties": {
      "publisher": "Microsoft.Powershell",
      "type": "DSC",
      "typeHandlerVersion": "2.9",
      "autoUpgradeMinorVersion": true,
      "settings": {
        "configuration": {
          "url": "publicstoragebloburi/DSC/DSC.zip",
          "script": "Main.ps1",
          "function": "Main"
        },
        "configurationArguments": {
          "MachineName": "localhost",
          "WebDeployPackagePath": PublicStorageBlobPath_App.zip",
          "UserName": "[parameters('adminUsername')]",
          "Password": "[parameters('adminPassword')]",
          "AppName": "FileScanApp",
          "AppPath": "C:\inetpub\dev\MyWebApp"

        }
  }

Main.ps1 文件和名为 Main 的配置确实存在。 Main.ps1 位于 ZIP 存档的根目录中。当扩展名在 VM 上为 运行 时,它会尝试在以下目录中找到 Main.ps1 文件:C:\Packages\Plugins\Microsoft.Powershell.DSC.71.1.0\bin..\DSCWork\DSC.1\Main.ps1 ,但是当我远程连接到机器时,文件夹中不存在 Main.ps1 并且出现以下错误:

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"Conflict", "message":"{\r\n \"status\": \"Failed\",\r\n \"error\": {\r\n \"code\": \"ResourceDeploymentFailure\",\r\n \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n \"details\": [\r\n {\r\n \"code\": \"VMExtensionProvisioningError\",\r\n \"message\": \"VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: \"DSC 扩展收到不正确的输入:执行脚本或模块时出错'Main.ps1': 术语 'C:\Packages\Plugins\Microsoft.Powershell.DSC\2.71.1.0\bin\..\DSCWork\DSC.1\Main.ps1' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,或者如果包含路径,请验证该路径正确并重试。\n请更正输入并重试执行扩展。\\".\"\r\n }\r\n ]\r\n }\r\n}"} ]}

有人可以告诉我,我做错了什么吗?我按照这个方法,这是在 github 上可用的官方示例 ARM 模板中实现的。谢谢!

配置对象中的 url 属性 需要是可在 Internet 上访问的 url。 zip 文件将下载到 VM 上的该位置,并从那里 运行。模板不需要知道它在 VM 上的存储位置,但它确实需要知道在 Internet 上的何处可以找到它。

这是一个示例,展示了如何使其端到端工作:https://github.com/Azure/azure-quickstart-templates/blob/master/201-vm-win-iis-app-ssl/azuredeploy.json

(还有几个)

根据我的评论,我遇到了同样的问题,请检查您的 DSC.zip 文件。我的 zip 文件是 /DSC/script.ps1。应该是 /script.ps1

这就是它找不到我的文件的原因。