Skip to content

Copilot/az compute update galleryimage feature#29368

Merged
VeryEarly merged 7 commits intoAzure:mainfrom
purbch:copilot/az-compute-update-galleryimage-feature
Apr 13, 2026
Merged

Copilot/az compute update galleryimage feature#29368
VeryEarly merged 7 commits intoAzure:mainfrom
purbch:copilot/az-compute-update-galleryimage-feature

Conversation

@purbch
Copy link
Copy Markdown
Member

@purbch purbch commented Apr 3, 2026

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

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copilot AI and others added 2 commits April 2, 2026 20:05
Copilot AI review requested due to automatic review settings April 3, 2026 07:24
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -Feature and -AllowUpdateImage parameters to Update-AzGalleryImageDefinition (generated cmdlet implementation).
  • Extended PSGalleryImage to expose AllowUpdateImage on 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.

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@VeryEarly VeryEarly self-assigned this Apr 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

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>
Copilot AI review requested due to automatic review settings April 7, 2026 07:11
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 7 changed files in this pull request and generated 1 comment.

@VeryEarly
Copy link
Copy Markdown
Collaborator

Hi @purbch ,
Please follow the CLA instruction in comment

Copy link
Copy Markdown
Member

@audreyttt audreyttt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, minor test change needed

Accept wildcard characters: False
```

### -Feature
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move these so that they follow the alphabetical order of the other parameters?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


$diskControllerUpdated = $updatedDefinition.Features | Where-Object { $_.Name -eq 'DiskControllerTypes' };
Assert-NotNull $diskControllerUpdated;
Assert-AreEqual $diskControllerUpdated.Value 'SCSI';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- 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>
@purbch
Copy link
Copy Markdown
Member Author

purbch commented Apr 9, 2026

@purbch please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Member

@audreyttt audreyttt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings April 10, 2026 19:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 7 changed files in this pull request and generated 3 comments.

Comment on lines +78 to +79
$DiskControllerType = @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'}
$SecurityType = @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
$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'}

Copilot uses AI. Check for mistakes.
Comment on lines +1283 to +1286
-Name $definitionName -Feature $features -AllowUpdateImage $true;

# Verify the updated definition
$updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
-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;

Copilot uses AI. Check for mistakes.
Comment on lines +526 to +530
galleryImage.Features = new List<GalleryImageFeature>();
for (int i = 0; i < this.Feature.Length; i++)
{
galleryImage.Features.Add(this.Feature[i]);
}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@VeryEarly VeryEarly enabled auto-merge (squash) April 13, 2026 03:15
@VeryEarly VeryEarly merged commit 373ba27 into Azure:main Apr 13, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants