azuredevops-buildagents icon indicating copy to clipboard operation
azuredevops-buildagents copied to clipboard

I can not run the pipeline and I not sure why..

Open karrziloo opened this issue 3 years ago • 9 comments

I get pwsh is not found, I did follow the instructions but I do not what I have miss or why is not working , I'm learning azure devops image

karrziloo avatar May 24 '21 19:05 karrziloo

the same issue

CurlyBytes avatar Aug 05 '21 01:08 CurlyBytes

@karrziloo Are you still experiencing this? From the other issues and reactions, I assume it worked out in the end for you @CurlyBytes ?

YannickRe avatar Aug 11 '21 09:08 YannickRe

Update - I've managed to resolve this. The root cause for me at least was the image not getting correctly associated with the vmss during the first run of the pipeline. I tried updating the vmss image with PS this still didn't work correctly. The solution was to re-create the vmss specifying the created image and the pipeline to build the windows agent pool is now running with no PS errors. I used the command below to create the Ubuntu vmss.

az vmss create --name vmsuksshdazdo02 --resource-group <resourceGroup> --image /subscriptions/<subscriptionID/resourceGroups/<resourceGroup/providers/Microsoft.Compute/images/ubuntu2004-12 --vm-sku Standard_D4s_v4 --storage-sku StandardSSD_LRS --authentication-type SSH --instance-count 0 --disable-overprovision --upgrade-policy-mode manual --single-placement-group false --platform-fault-domain-count 1 --load-balancer '""' --subnet "/subscriptions/<subscriptionID>/resourceGroups/<resourcegroup>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/<subnetName" --tags System="Azure DevOps Build Agent" Billing="Platform Operations" ` --generate-ssh-keys

The error updating the vmss image only happens on the first run though, once you've created the vmss using the generated image subsequent runs of the pipeline update the vmss successfully, it seems to be pre-creating the vmss according to the MS documentation it doesn't match the created image type and hence fails, a minor issue.

@karrziloo Are you still experiencing this? From the other issues and reactions, I assume it worked out in the end for you @CurlyBytes ?

Hey Yannick, firstly thanks for providing this pipeline in the first place! I'm getting the same issue as of today. I was able to use the pipeline to deploy the Ubuntu 2004 image (on a paid MS hosted windows agent) albeit it failed to update the vmss (A different issue), see below.

Starting: Update Virtual Machine Scale Set

Task : PowerShell Description : Run a PowerShell script on Linux, macOS, or Windows Version : 2.190.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell

Generating script. Formatted command: . 'D:\a\1\s\azure-devops\azuredevops-buildagents-main\scripts\update-vmss.ps1' -ClientId 89e587ca-ab18-4f28-97b4-36dd9f674196 -ClientSecret c2bf427b-d656-4dc7-85bf-7dd89b0b2112 -ResourceGroup rg-uks-shd-azdo-01 -TenantId 6bed4464-58b6-47ce-aa63-d47b1a00d90e -VmssName vmsuksshdazdo02 ` -ManagedImageId "/subscriptions/2ea5d2c5-3538-47f4-ac49-e263d06cf22d/resourceGroups/rg-uks-shd-pack-01/providers/Microsoft.Compute/images/ubuntu2004-12" ========================== Starting Command Output =========================== "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a_temp\e1fb4d4e-26bf-4870-9325-9cb6a786ec8c.ps1'" ERROR: (OperationNotAllowed) The Image type for a Virtual Machine Scale Set may not be changed. Updated Virtual Machine Scale Set with new Azure Image: /subscriptions/2ea5d2c5-3538-47f4-ac49-e263d06cf22d/resourceGroups/rg-uks-shd-pack-01/providers/Microsoft.Compute/images/ubuntu2004-12 ##[error]PowerShell exited with code '1'. Finishing: Update Virtual Machine Scale Set

I worked around this by updating the vmss image ID manually using PS Set-AzVmssStorageProfile -VirtualMachineScaleSet $vmss -ImageReferenceId $ManagedImageId and the vmss seems to be working properly, creating instances as required by DevOps.

I then tried to use my new agent-pool to create the Windows image and have hit exactly the issue as described by Karrziloo

MusingsOfATechnicalMind avatar Aug 12 '21 20:08 MusingsOfATechnicalMind

I'm having the same issue with a vmss using ubuntu 20.04 lts (focal). Anything I'm missing there?

4865783a5d avatar May 07 '22 11:05 4865783a5d

Which issue are you hitting?

YannickRe avatar May 07 '22 20:05 YannickRe

I created a VM Scale Set with Ubuntu 20.04 LTS (Focal) and added a build agent pool in DevOps. Role Assignments etc. are set up. On starting the pipeline, it fails in the step 'set image template variables'.

##[error]Unable to locate executable file: 'pwsh'.

Thanks by the way, really appreciate your work!

Edit: Apparently, pwsh does not come with the Build Agent Tools so you have to install it manually:

Add

- script: | wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh; rm install-powershell.sh

If you don't use any other means to install it beforehand.

4865783a5d avatar May 07 '22 20:05 4865783a5d

I also ran into the "The Image type for a Virtual Machine Scale Set may not be changed." issue on first run. It seems that the VMSS creation using a vanilla Windows2019 image from the Microsoft Azure Catalog (in my case), creates the VMSS using Generation 2 VMs while the Virtual Environment process to generate VMSS agent OS images creates Generation 1 VM images. VMSS won't allow the VM type to be changed. I am currently testing @MusingsOfATechnicalMind idea of re-creating my VMSS but using the image created from my first pipeline run rather than the Microsoft image.

dstrzelec avatar May 18 '22 20:05 dstrzelec

@dstrzelec I'm sorry about that. I recently noticed this too:

  1. Create a VMSS based on a Windows Server image provided by Azure
  2. Run the pipeline on that VMSS, have a new VHD created
  3. The pipeline tries to attach that VHD to the VMSS and fails with "The Image type for a Virtual Machine Scale Set may not be changed"

I resolved it like this:

  1. Remove the VMSS based agent from DevOps
  2. Remove the VMSS from Azure
  3. Create a new VMSS with the newly created VHD
  4. Re-run the failed jobs from the pipeline that created the VHD

As a result it "re-attaches" the new VHD again to the VMSS, the pipeline shows a succeeded result, and for future runs it will work. I don't know about a better solution yet, sorry to not have shared that before.

YannickRe avatar May 23 '22 19:05 YannickRe

@YannickRe Yes, that is what I ended up doing along with the notes from @MusingsOfATechnicalMind which led me to that path.

dstrzelec avatar Jun 01 '22 21:06 dstrzelec

Just because my OCD is itching - can this be closed -it looks like the issue report is now self fixed

Marcus-James-Adams avatar Mar 07 '23 10:03 Marcus-James-Adams

It was still open because it was a reminder for me to fix this, but the PR with the Gallery will fix this 🙂

YannickRe avatar Mar 07 '23 11:03 YannickRe