Open jerryc3 opened 1 year ago
@jerryc3 Thank you for reporting this issue. We are triaging and will get back to you as soon as we are able.
I see a SharedGalleryImageId parameter was added in add sharedGalleryImageId to VM/VMSS by grizzlytheodore · Pull Request #21139 · Azure/azure-powershell (github.com)
But in your issue you are using -ImageReferenceId "/SharedGalleries/WindowsServer.1P.Canary/images/2022-datacenter-azure-edition/versions/latest"
Is this what you intended? And if yes, then why did we add the sharedgalleryimageId parameter?
Hey @haagha ,
I think the example was wrong in the original issue. the issue is pertaining to the "SharedGalleryImageId" parameter
if -sharedGalleryImageId is provided, it should map as follows:
"storageProfile": { "imageReference": { "sharedGalleryImageId": "/SharedGalleries/...." } }
the current code has a bug and imageReferenceId == null when sharedGalleryImageId is passed. It ends up never getting used : }, StorageProfile = new VirtualMachineScaleSetStorageProfile { ImageReference = (imageReferenceId == null) ? imageAndOsType?.Image : (imageReferenceId.ToLower().StartsWith("/communitygalleries/") ? new ImageReference { CommunityGalleryImageId = imageReferenceId, SharedGalleryImageId = sharedImageGalleryId } : new ImageReference { Id = imageReferenceId, SharedGalleryImageId = sharedImageGalleryId }), DataDisks = DataDiskStrategy.CreateVmssDataDisks( imageAndOsType?.DataDiskLuns, dataDisks), DiskControllerType = diskControllerType },
Also having this issue
$VmConfig = New-AzVMConfig -VMName testvm -VMSize Standard_B2s -SharedGalleryImageId /SharedGalleries/<sub>-<gallery>/Images/<definition/Versions/<version> -Location WestUS2
Write-Output $VmConfig.StorageProfile.ImageReference
Publisher :
Offer :
Sku :
Version :
ExactVersion :
SharedGalleryImageId : /SharedGalleries/<sub>-<gallery>/Images/<definition/Versions/<version>
CommunityGalleryImageId :
Id :
And when I launch the VM
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.retrieveImageVersion(String publisher, String offer, String sku, String version)
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.retrieveSpecificImageFromNotId()
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.DefaultExecuteCmdlet()
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
System.Management.Automation.InvocationInfo
Seems to happen because no ID and no Publisher/Offer/Sku
@TravisCragg-MSFT @haagha @isra-fel Any update ? I believe it is related to this: https://github.com/Azure/azure-powershell/blob/main/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs#L966-L967
if (this.VM.StorageProfile?.ImageReference?.Id != null)
{
https://github.com/Azure/azure-powershell/pull/24413 This should fix it. I have build the Az.Compute module with this PR and tested it, it works as expected.
up
@TravisCragg-MSFT @haagha @isra-fel ?
Hi @mfortin, sorry for the delayed response. Was #24413 able to fix? Or are you still running into this issue?
Description
Powershell command:
New-AzVmss -Credential <vm-cred> -VMScaleSetName <vmss-name> -SharedGalleryImageId "/SharedGalleries/WindowsServer.1P.Canary/images/2022-datacenter-azure-edition/versions/latest" -SecurityType "TrustedLaunch" -EnableSecureBoot $true -EnableVtpm $true -Location "eastus2euap"
results in VMSS request entity of:
The expected entity is
Bug code location: https://github.com/Azure/azure-powershell/blob/main/src/Compute/Compute/Strategies/ComputeRp/VirtualMachineScaleSetStrategy.cs#L117C52-L117C52
Since SharedGalleryImageId is provided, ImageReferenceId is null. This results
ImageReference
being set toimageAndOsType?.Image
and sharedGalleryImageId is not set.Issue script & Debug output
Environment data
Module versions
Error output
No response