Copilot/az compute update galleryimage feature#29368
Conversation
…eDefinition cmdlet Agent-Logs-Url: https://github.com/Azure/azure-powershell/sessions/44ef71fe-10fa-4071-b5f0-ce5b458f2586 Co-authored-by: audreyttt <225061541+audreyttt@users.noreply.github.com>
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
There was a problem hiding this comment.
Pull request overview
This PR extends the Az.Compute gallery image definition update surface to support updating gallery image features (including StartsAtVersion) and the accompanying AllowUpdateImage flag, with documentation and scenario test coverage.
Changes:
- Added
-Featureand-AllowUpdateImageparameters toUpdate-AzGalleryImageDefinition(generated cmdlet implementation). - Extended
PSGalleryImageto exposeAllowUpdateImageon outputs. - Updated cmdlet help + Compute
ChangeLog.md, and added a new gallery scenario test.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Compute/Compute/help/Update-AzGalleryImageDefinition.md | Documents the new -Feature / -AllowUpdateImage parameters and provides an example. |
| src/Compute/Compute/Generated/Models/PSGalleryImage.cs | Adds AllowUpdateImage to the PowerShell model returned for gallery image definitions. |
| src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs | Implements sending features and allowUpdateImage on update requests; adds the new parameters. |
| src/Compute/Compute/ChangeLog.md | Release notes for the new update capability. |
| src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1 | Adds scenario coverage for updating features with StartsAtVersion and AllowUpdateImage. |
| src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs | Registers the new scenario test for check-in runs. |
src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs
Show resolved
Hide resolved
src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…rding - Set StartsAtVersion during gallery image definition creation instead of update, as the Azure API does not allow changing this property post-creation - Remove AllowUpdateImage assertion as the property is not populated in the PSGalleryImage response model - Add session recording file for Playback mode in CI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs
Show resolved
Hide resolved
|
Hi @purbch , |
audreyttt
left a comment
There was a problem hiding this comment.
Overall looks good, minor test change needed
| Accept wildcard characters: False | ||
| ``` | ||
|
|
||
| ### -Feature |
There was a problem hiding this comment.
Can you move these so that they follow the alphabetical order of the other parameters?
|
|
||
| $diskControllerUpdated = $updatedDefinition.Features | Where-Object { $_.Name -eq 'DiskControllerTypes' }; | ||
| Assert-NotNull $diskControllerUpdated; | ||
| Assert-AreEqual $diskControllerUpdated.Value 'SCSI'; |
There was a problem hiding this comment.
The feature values in the updatedDefinition seem to match the initialFeatures, so we should change the test to make sure we are actually checking that new values are set. $features is equal to $initialFeatures so we are not actually updating anything.
- Move -AllowUpdateImage and -Feature parameters to alphabetical order in Update-AzGalleryImageDefinition.md help file - Update test to use different feature values for the update operation so it actually verifies the update works (changed SecurityType, DiskControllerTypes, and StartsAtVersion values) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service agree company="Microsoft" |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
audreyttt
left a comment
There was a problem hiding this comment.
Please record the test again and ensure it works in playback mode
- Changed DiskControllerTypes value from SCSI to SCSI, NVMe (valid update) - Kept StartsAtVersion at 4.0.0 (API does not allow changing this) - Re-recorded session recording with updated feature values Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| $DiskControllerType = @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'} | ||
| $SecurityType = @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'} |
There was a problem hiding this comment.
The example builds -Feature values as hashtables, but the parameter type is Microsoft.Azure.Management.Compute.Models.GalleryImageFeature[]. Unless a custom type converter exists, this example may not work as written. Update the example to construct actual GalleryImageFeature objects (e.g., via New-Object ... -Property @{...} or a strongly-typed cast) to match real usage (and align with the new scenario test).
| $DiskControllerType = @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'} | |
| $SecurityType = @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'} | |
| $DiskControllerType = New-Object Microsoft.Azure.Management.Compute.Models.GalleryImageFeature -Property @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'} | |
| $SecurityType = New-Object Microsoft.Azure.Management.Compute.Models.GalleryImageFeature -Property @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'} |
| -Name $definitionName -Feature $features -AllowUpdateImage $true; | ||
|
|
||
| # Verify the updated definition | ||
| $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; |
There was a problem hiding this comment.
The test uses Update-AzGalleryImageDefinition and Get-AzGalleryImageDefinition without -ErrorAction Stop. In these scenario tests, non-terminating errors can lead to false positives or harder-to-diagnose failures later in the script. Consider adding -ErrorAction Stop (mandatory for reliability) to the update and subsequent get so the test fails at the real error site.
| -Name $definitionName -Feature $features -AllowUpdateImage $true; | |
| # Verify the updated definition | |
| $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; | |
| -Name $definitionName -Feature $features -AllowUpdateImage $true -ErrorAction Stop; | |
| # Verify the updated definition | |
| $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName -ErrorAction Stop; |
| galleryImage.Features = new List<GalleryImageFeature>(); | ||
| for (int i = 0; i < this.Feature.Length; i++) | ||
| { | ||
| galleryImage.Features.Add(this.Feature[i]); | ||
| } |
There was a problem hiding this comment.
This manual copy loop is more verbose than necessary and makes the intent (assigning all provided features) less clear. Prefer constructing the list directly from the array (e.g., via ToList()), which reduces code and the chance of future off-by-one / null-handling issues. This is optional but would improve readability.
| galleryImage.Features = new List<GalleryImageFeature>(); | |
| for (int i = 0; i < this.Feature.Length; i++) | |
| { | |
| galleryImage.Features.Add(this.Feature[i]); | |
| } | |
| galleryImage.Features = this.Feature.ToList(); |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Description
Adding the changes to support UpdateImage feature which has a new property called startsAtVersion to define the image version onwards the updated image feature is supported and allowUpdateImage to separate it from the Create request for the image feature
Design: https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/1541
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.