Closed slaterx closed 1 month ago
You can actually use the managed image name but only if you are deploying the VM into the same resource group as the image... otherwise the managed image id is required. I agree the documentation should reflect this. In fairness, it is also not clear from the az vm create
documentation: https://learn.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az-vm-create
I agree that vm creation docs requires more love and care, it is not clear how this matters.
In our case, we build the image in one disposable resource group and maintain the runners in a groomed resource group, so it doesn't make sense to build the image there. I'll have to hack CreateAzureVMFromPackerTemplate to fit my case, but would be great to have the code considering images inside and outside the resource group.
Are we allowed to propose PRs?
Yes, to my understanding of https://github.com/actions/runner-images/blob/main/CONTRIBUTING.md anyone can contribute and create pull requests. ^^
I would say this is by desing though since the script is only executing...
az vm create `
--resource-group $ResourceGroupName `
--name $VirtualMachineName `
--image $ManagedImageName `
--size $vmSize `
--admin-username $AdminUsername `
--admin-password $AdminPassword `
--nics $networkId `
--subscription $subscriptionId `
--location $AzureLocation
...and the --image
parameter accepts both, the Managed Image Id as well as the name (if the image resides in the resource group that is passed in --resource-group
)... Imho, changing the parameter $ManagedImageName
to $ManagedImage
and updating the function description would probably do it already, but I guess depends on your use case. :-)
As dusted in the docs you should first generate the managed image and only then use the script to run packer on it, in your specific case managed image you specify does not exist in the RG you specified that is why you see this error, it is expected.
Description
Hi Team,
I am trying to create new action runner based on latest code that creates managed image instead of VHD. Documentation states to use Managed Image Name (such as Runner-Image-Ubuntu2204), but doing as such lead to error:
If this is by design, then maybe we should consider update the documentation to use the actual custom image ID that is generated after packer completes the build?
Platforms affected
Runner images affected
Image version and build link
actions-runner-linux-x64-2.315.0
Is it regression?
no
Expected behavior
helpers/CreateAzureVMFromPackerTemplate.ps1 completes VM creation
Actual behavior
helpers/CreateAzureVMFromPackerTemplate.ps1 fails to create VM with error:
Repro steps
Install-Module -Name Az -Repository PSGallery -Force Update-AzConfig -DefaultSubscriptionForLogin * Import-Module .\helpers\CreateAzureVMFromPackerTemplate.ps1 CreateAzureVMFromPackerTemplate -SubscriptionId -ResourceGroupName -ManagedImageName "Runner-Image-Ubuntu2204" -VirtualMachineName githubvm -AdminUsername ** -AdminPassword ** -AzureLocation *