本文介绍了Azure ARM DSC规模集部署-无法找到脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to deploy Virtual Machine Scale Set to Azure using ARM Template and Desired State Configuration (DSC). I have created DSC configuraiton and validated it on a separate VM that it is working. In ARM template I have following definition of DSC extension:

{
    "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 \ 2.71.1.0 \ bin .. \ DSCWork \ DSC.1 \ Main .ps1,但是当我远程访问计算机时,Main.ps1不在文件夹中,并且出现以下错误:

Main.ps1 file and also Configratuion with name Main do exist. Main.ps1 is located in the root directory of the ZIP Archive. When the extension is running on the VM, it is trying to locate Main.ps1 file in following directory: C:\Packages\Plugins\Microsoft.Powershell.DSC\2.71.1.0\bin..\DSCWork\DSC.1\Main.ps1 , but when I remoted to the machine the Main.ps1 is not present in the folder and I am getting following error:

{代码":"DeploymentFailed",消息":"至少一项资源部署操作失败.请列出部署操作以了解详细信息.请参阅 https://aka.ms/arm-debug 了解使用详细信息.",详细信息":[{代码":冲突",消息":"{\ r \ n \状态\":\失败\",\ r \ n \错误\":{\ r \ n \代码\":\资源部署失败\",\ r \ n \消息\ :\"资源操作以终端供应状态'Failed'完成.\,\ r \ n \" details \:[\ r \ n {\ r \ n \" code \:\" VMExtensionProvisioningError \",\ r \ n \"message \":\"VM在处理扩展名'Microsoft.Powershell.DSC'时报告了故障.错误消息:\\"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}}]}

{"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: \\"The DSC Extension received an incorrect input: An error occurred while executing script or module 'Main.ps1': The term 'C:\\Packages\\Plugins\\Microsoft.Powershell.DSC\\2.71.1.0\\bin\\..\\DSCWork\\DSC.1\\Main.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again..\nPlease correct the input and retry executing the extension.\\".\"\r\n }\r\n ]\r\n }\r\n}"}]}

请有人告诉我,我做错了什么?我遵循的方式是在 github .谢谢!

Please can somebody tell me, what am I doing wrong? I was following the way, this is implemented within the official sample ARM templates available on github. Thank you!

推荐答案

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

As per my comment I was experiencing the same problem check your DSC.zip file. My zip file was /DSC/script.ps1. It should be /script.ps1

这就是为什么找不到适合我的文件的原因.

This is why it couldn't find the file for me.

这篇关于Azure ARM DSC规模集部署-无法找到脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 01:34