Skip to content

Commit

Permalink
add ExlucdeFromLatest field to TargetRegion parameter New/Update-AzGa…
Browse files Browse the repository at this point in the history
…lleryImageVersion (Azure#24531)

* add ExlucdeFromLatest to Target Region object

* update changelog

* updated changelog

* add test

* fix test

---------

Co-authored-by: Theodore Chang <theodore.l.chang@gmail.com>
  • Loading branch information
grizzlytheodore and Theodore Chang authored Apr 10, 2024
1 parent 7bbaa7b commit c990ded
Show file tree
Hide file tree
Showing 4 changed files with 1,803 additions and 822 deletions.
15 changes: 15 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ function Test-GalleryVersionWithSourceImageVMId

# Setup Image Version
$imageVersionName = "1.0.0";
$targetRegions = @(@{Name=$loc;ReplicaCount=1;});
$paramNewAzImageVer = @{
ResourceGroupName = $rgname
GalleryName = $galleryName
Expand All @@ -866,11 +867,25 @@ function Test-GalleryVersionWithSourceImageVMId
SourceImageVMId = $vm.Id
ErrorAction = 'Stop'
StorageAccountType = $storageAccountSku
TargetRegion = $targetRegions
}
$galversion = New-AzGalleryImageVersion @paramNewAzImageVer;

# Assert VMId in version was set to the vm.Id value and was created.
Assert-AreEqual $galversion.StorageProfile.Source.VirtualMachineId $vm.Id;
Assert-Null $galversion.PublishingProfile.TargetRegion ExcludeFromLatest;

$targetRegions = @{Name=$loc;ReplicaCount=1; ExcludeFromLatest=$true}

Update-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $definitionName -Name $imageVersionName `
-TargetRegion $targetRegions;

$galversion = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $definitionName -Name $imageVersionName;

Assert-AreEqual $galversion.PublishingProfile.TargetRegions.ExcludeFromLatest $true;

}
finally
{
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
`Get-AzVmss` will no longer allow empty values to `ResourceGroupName` and `VMScaleSetName` to avoid a bug where it will just return nothing.
* Added a new parameter `-SharingProfile` to `New-AzCapacityReservationGroup` and `Update-AzCapacityReservationGroup`.
* Added the new parameter `SourceImageVMId` to the `New-AzGalleryImageVersion` cmdlet. Also added some error messages for this new parameter and the existing parameter `SourceImageId`.
* Updated parameter `-TargetRegion` in `New-AzGalleryImageVersion` and `Update-AzGalleryImageVersion` to accept `ExcludeFromLatest` field.

## Version 7.1.2
* Fixed `New-AzVM` when a source image is specified to avoid an error on the `Version` value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public override void ExecuteCmdlet()
Name = (string)t["Name"],
RegionalReplicaCount = (int?)t["ReplicaCount"],
StorageAccountType = (string)t["StorageAccountType"],
ExcludeFromLatest = (bool?)t["ExcludeFromLatest"],
};
if (t["Encryption"] != null)
{
Expand Down Expand Up @@ -505,6 +506,7 @@ public override void ExecuteCmdlet()
Name = (string)t["Name"],
RegionalReplicaCount = (int?)t["ReplicaCount"],
StorageAccountType = (string)t["StorageAccountType"],
ExcludeFromLatest = (bool?)t["ExcludeFromLatest"],
};
if (t["Encryption"] != null)
{
Expand Down

0 comments on commit c990ded

Please sign in to comment.