0
votes

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 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:

{"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}"}]}

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!

2
this is the place where it should be, so log into the vm after the extension has failed and verify that the file is there C:\Packages\Plugins\Microsoft.Powershell.DSC\2.71.1.0\DSCWork\DSC.1\Main.ps1. if its not, something is wrong with your dsc archive4c74356b41
I checked that, and it isn't there. I edited also my question. The Archive contains only Main.ps1 file and additional modules I use within the configuration. Archive is uploaded in publicly available blob container. Please, do you have idea, where I may have made mistake when creating Archive? Thank yuo.marek_lani
@marek_lani did you solve this? I get the same error, I had a look at the logs and it appears to have put my script here C:\Program Files\WindowsPowerShell\Modules\DSC in the log it appears to be trying to run it from An error occurred while executing script or module 'script.ps1': The term 'C:\Packages\Plugins\Microsoft.Powershell.DSC\2.71.1.0\bin\..\DSCWork\DSC.0\script.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program.Boomerang

2 Answers

1
votes

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.

1
votes

The url property in the configuration object needs to be a url that's accessible on the internet. The zip file is downloaded to that location on the VM and run from there. Where it's stored on the VM isn't something the template needs to know, but it does need to know where to find it on the internet.

Here is a sample that shows how to make it work end to end: https://github.com/Azure/azure-quickstart-templates/blob/master/201-vm-win-iis-app-ssl/azuredeploy.json

(there are a few others too)