YannickRe / azuredevops-buildagents

Generate self-hosted build agents for Azure DevOps, just like Microsoft does.
MIT License
151 stars 90 forks source link

A parameter cannot be found that matches parameter name: OsVhdUri #40

Closed jok0 closed 1 year ago

jok0 commented 1 year ago

Hi, i am having trouble on the Managed Image Generation job.

The machine builds successfully but it looks like the OsVhdUri is not being outputted so the variable isn't being passed into the create-managedimage.ps1 script.

I am building this with an Azure Hosted VM and trying to build 2022-Datacenter.

Error in question is:

D:\a\1\a\VMSSFiles\Scripts\Setup\create-managedimage.ps1 : A parameter cannot be found that matches parameter name 
'OsVhdUri'.
At D:\a\_temp\fe1cd036-928c-4234dc-86e7-33dsrf344a3dc1.ps1:4 char:426
+ ... 5c28 ` -Location UKSOUTH ` -ImageType windows2022 ` -OsVhdUri  ` -OsT ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [create-managedimage.ps1], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NamedParameterNotFound,create-managedimage.ps1

Any assistance on this would be super. I have tried to debug this for a good couple of days now but ran out of ideas. Thanks

Oh, also, i don't know if it's worth mentioning but i am not importing the runner-images. I am using Azures image. Could this be the problem? This is my packer build file.

{
    "builders": [{
      "type": "azure-arm",

      "client_id": "[client_id]",
      "client_secret": "[client_secret]",
      "tenant_id": "[tenant]",
      "subscription_id": "[sub]",

      "managed_image_resource_group_name": "rg-packer-test",
      "managed_image_name": "myPackerImage",

      "os_type": "Windows",
      "image_publisher": "MicrosoftWindowsServer",
      "image_offer": "WindowsServer",
      "image_sku": "2022-Datacenter",

      "communicator": "winrm",
      "winrm_use_ssl": true,
      "winrm_insecure": true,
      "winrm_timeout": "10m",
      "winrm_username": "packer",

      "azure_tags": {
          "dept": "Cloud",
          "task": "Image deployment"
      },

      "build_resource_group_name": "rg-packerbuild-test",
      "vm_size": "Standard_D2_v2"
    }],
    "provisioners": [
        {
        "type": "powershell",
        "scripts": [
            "{{ template_dir }}/scripts/installers/Install-AzureCli.ps1"
        ]
    },
      {
      "type": "powershell",
      "inline": [
        "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
        "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10  } else { break } }"
      ]
    }
  ]
  }
YannickRe commented 1 year ago

You aren't using my setup and it doesn't work? That looks to be the problem, I'm afraid. I have created 3 new VM's today, the current version of my repo works...

Some things to look at:

That's all I can help with when you aren't using the runner-images repository, as this whole setup is based on that.