Skip to content

Commit

Permalink
[Compute] SharedGalleryImageId bug fix for New-Azvmss, New-Azvm (#23145)
Browse files Browse the repository at this point in the history
* changes

* bug fix

* Adding changelog
  • Loading branch information
haagha authored Nov 7, 2023
1 parent 944d498 commit 3d4fb23
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Removed unversioned and outdated images from New-AzVmss `-ImageName` argument completers.
* Added new parameters `-ElasticSanResourceId` and `-OptimizedForFrequentAttach` to `New-AzDiskConfig` cmdlet.
* Added new parameter `-ElasticSanResourceId` to `New-AzSnapshotConfig` cmdlet.
* Fixed `New-AzVmss` and `New-Azvm` to use `SharedGalleryImageId` parameter.

## Version 6.3.0
* Added `-Hibernate` switch parameter to `Stop-AzVmss` default parameter set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,23 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = (imageReferenceId == null) ? imageAndOsType?.Image : (imageReferenceId.ToLower().StartsWith("/communitygalleries/") ? new ImageReference
ImageReference = (imageReferenceId == null && sharedImageGalleryId == null) ? imageAndOsType?.Image
: (sharedImageGalleryId != null ? new ImageReference
{
CommunityGalleryImageId = imageReferenceId,
SharedGalleryImageId = sharedImageGalleryId
} : new ImageReference
}
: (imageReferenceId.ToLower().StartsWith("/communitygalleries/") ? new ImageReference
{
Id = imageReferenceId,
SharedGalleryImageId = sharedImageGalleryId
}),
CommunityGalleryImageId = imageReferenceId,
}
: (imageReferenceId.ToLower().StartsWith("/sharedgalleries/") ? new ImageReference
{
SharedGalleryImageId = imageReferenceId
}
: new ImageReference
{
Id = imageReferenceId
}))),
DataDisks = DataDiskStrategy.CreateVmssDataDisks(
imageAndOsType?.DataDiskLuns, dataDisks),
DiskControllerType = diskControllerType
Expand Down
27 changes: 17 additions & 10 deletions src/Compute/Compute/Strategies/ComputeRp/VirtualMachineStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,23 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
},
StorageProfile = new StorageProfile
{
//ImageReference = (imageReferenceId.Contains("CommunityGalleries")) ? new ImageReference { CommunityGalleryImageId = imageReferenceId}
ImageReference = (imageReferenceId == null) ? imageAndOsType?.Image : (imageReferenceId.ToLower().StartsWith("/communitygalleries/") ? new ImageReference
{
CommunityGalleryImageId = imageReferenceId,
SharedGalleryImageId = sharedGalleryImageId
}: new ImageReference
{
Id = imageReferenceId,
SharedGalleryImageId = sharedGalleryImageId
}),
ImageReference = (imageReferenceId == null && sharedGalleryImageId == null) ? imageAndOsType?.Image
: (sharedGalleryImageId != null ? new ImageReference
{
SharedGalleryImageId = sharedGalleryImageId
}
: (imageReferenceId.ToLower().StartsWith("/communitygalleries/") ? new ImageReference
{
CommunityGalleryImageId = imageReferenceId,
}
: (imageReferenceId.ToLower().StartsWith("/sharedgalleries/") ? new ImageReference
{
SharedGalleryImageId = imageReferenceId
}
: new ImageReference
{
Id = imageReferenceId
}))),
OsDisk = new OSDisk(
createOption: DiskCreateOptionTypes.FromImage,
deleteOption: osDiskDeleteOption),
Expand Down

0 comments on commit 3d4fb23

Please sign in to comment.