latest powershell changes for azurestackhci#29211
latest powershell changes for azurestackhci#29211shraddhasun wants to merge 13 commits intoAzure:mainfrom
Conversation
| 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 updates the Az.StackHCIVM AutoRest custom PowerShell cmdlets to align with newer model type names (singular interfaces), introduces additional VM lifecycle operations, and tweaks some cmdlet behavior/documentation.
Changes:
- Update many cmdlets’
.Outputs/[OutputType]declarations from plural to singular model interfaces. - Add new custom cmdlets for VM instance operations (
Save-*,Suspend-*) and adjustStart-*implementation details. - Modify
New-AzStackHCIVMImageandNew-AzStackHCIVMVirtualMachineparameter handling/typing and adjust some custom docs/validation strings.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/StackHCIVM/StackHCIVM.Autorest/custom/utilities/VirtualNetworkValidations.ps1 | Updates validation error strings for virtual network-related objects. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMVirtualHardDisk_ByResourceId.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMStoragePath_ByResourceId.ps1 | Adjusts declared output interface to singular form and updates comment-based help output type. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMNetworkInterface_ByResourceId.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMLogicalNetwork_ByResourceId.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMImage.ps1 | Adjusts declared output interfaces to singular forms per parameter set. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1 | Adds a new custom VM “suspend” cmdlet wrapper around internal implementation. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Start-AzStackHCIVMVirtualMachine_New.ps1 | Refines resource-id parsing / variable usage in the start cmdlet wrapper. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1 | Adds a new custom VM “save” cmdlet wrapper around internal implementation. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/README.md | Normalizes documentation paths to use ../ style separators. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1 | Changes AdminPassword type and updates bound-parameter handling for VM creation. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualHardDisk_New.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMStoragePath_New.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMNetworkInterface_New.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMLogicalNetwork_New.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMImage.ps1 | Adjusts declared output interfaces, changes ImagePath typing, and skips sleeps during playback. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Get-AzStackHCIVmLogicalNetwork_ByResourceId2.ps1 | Fixes output interface naming for resource-id based get wrapper. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Get-AzStackHCIVmImage.ps1 | Adjusts declared output interfaces to singular forms. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Get-AzStackHCIVMVirtualHardDisk_ByResourceId.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Get-AzStackHCIVMStoragePath_ByResourceId.ps1 | Adjusts declared output interface to singular form. |
| src/StackHCIVM/StackHCIVM.Autorest/custom/Get-AzStackHCIVMNetworkInterface_ByResourceId.ps1 | Adjusts declared output interface to singular form. |
Comments suppressed due to low confidence (4)
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1:159
- Typo in comment: "provsioned" should be "provisioned".
# Used to indicate whether Arc for Servers agent onboarding should be triggered during the virtual machine creation process. VM Agent is provsioned by default. Please pass -ProvisionVMAgent:$false to disable.
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMImage.ps1:122
- Typo in parameter description: "marketplae" should be "marketplace".
# The name of the marketplae gallery image definition offer.
src/StackHCIVM/StackHCIVM.Autorest/custom/utilities/VirtualNetworkValidations.ps1:26
- The error message has a typo: "Accpeted" should be "Accepted".
Write-Error "Invalid Key specified in IpPool object. Accpeted values are 'Start', 'End', and 'Type'." -ErrorAction Stop
src/StackHCIVM/StackHCIVM.Autorest/custom/utilities/VirtualNetworkValidations.ps1:57
- The error message has a typo: "Accpeted" should be "Accepted".
Write-Error "Invalid Key specified in IpPool object. Accpeted values are 'AddressPrefix', 'Name', and 'NextHopIPAddress'." -ErrorAction Stop
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1
Outdated
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMStoragePath_ByResourceId.ps1
Outdated
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (6)
src/StackHCIVM/StackHCIVM.Autorest/custom/utilities/VirtualNetworkValidations.ps1:57
- Spelling error in error message: "Accpeted" should be "Accepted".
Write-Error "Invalid Key specified in IpPool object. Accpeted values are 'AddressPrefix', 'Name', and 'NextHopIPAddress'." -ErrorAction Stop
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1:159
- Spelling error in comment: "provsioned" should be "provisioned".
# Used to indicate whether Arc for Servers agent onboarding should be triggered during the virtual machine creation process. VM Agent is provsioned by default. Please pass -ProvisionVMAgent:$false to disable.
src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1:141
- The error message references module name "Az.StackHCIVm" (lowercase
m), which is inconsistent with the actual module nameAz.StackHCIVM. Fixing this avoids confusing guidance for users when handling this exception.
Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop
src/StackHCIVM/StackHCIVM.Autorest/custom/utilities/VirtualNetworkValidations.ps1:26
- Spelling error in error message: "Accpeted" should be "Accepted".
Write-Error "Invalid Key specified in IpPool object. Accpeted values are 'Start', 'End', and 'Type'." -ErrorAction Stop
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMImage.ps1:122
- Spelling error in parameter comment: "marketplae" should be "marketplace".
# The name of the marketplae gallery image definition offer.
src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1:141
- The error message references module name "Az.StackHCIVm" (lowercase
m), which is inconsistent with the actual module nameAz.StackHCIVM. Fixing this avoids confusing guidance for users when handling this exception.
Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop
|
|
||
| } else { | ||
| Write-Error "Invalid Key specified in IpPool object. Accepted values are 'AddressPrefix', 'Name', and 'NextHopIPAddress'." -ErrorAction Stop | ||
| Write-Error "Invalid Key specified in IpPool object. Accpeted values are 'AddressPrefix', 'Name', and 'NextHopIPAddress'." -ErrorAction Stop |
There was a problem hiding this comment.
The error message is misleading in Confirm-Routes: it says "IpPool object" but this branch validates Route keys. Update the message to reference the Route object so callers can diagnose the issue correctly.
| Write-Error "Invalid Key specified in IpPool object. Accpeted values are 'AddressPrefix', 'Name', and 'NextHopIPAddress'." -ErrorAction Stop | |
| Write-Error "Invalid Key specified in Route object. Accepted values are 'AddressPrefix', 'Name', and 'NextHopIPAddress'." -ErrorAction Stop |
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1
Outdated
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
e31ead6 to
673006d
Compare
src/StackHCIVM/StackHCIVM.Autorest/custom/Update-AzStackHCIVMVirtualHardDisk_ByResourceId.ps1
Outdated
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1
Outdated
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1
Outdated
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMImage.ps1
Outdated
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
673006d to
dbf2837
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (2)
src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1:142
- The error message references
Az.StackHCIVm(lowercasem), but the module name isAz.StackHCIVM. Update the message to use the correct module name so users can follow the instruction accurately.
if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){
Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop
} else {
src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1:142
- The error message references
Az.StackHCIVm(lowercasem), but the module name isAz.StackHCIVM. Update the message to use the correct module name so users can follow the instruction accurately.
if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){
Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop
} else {
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/New-AzStackHCIVMImage.ps1
Outdated
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Save-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
src/StackHCIVM/StackHCIVM.Autorest/custom/Suspend-AzStackHCIVMVirtualMachine_New.ps1
Show resolved
Hide resolved
| function Save-AzStackHCIVMVirtualMachine { | ||
| [OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IVirtualMachineInstance])] | ||
| [CmdletBinding( PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] |
There was a problem hiding this comment.
This PR adds/changes cmdlet surface area (new Save/Suspend cmdlets and parameter type changes). The module ChangeLog (src/StackHCIVM/StackHCIVM/ChangeLog.md) currently has an empty "Upcoming Release" section—please add an entry describing these changes (past tense) and regenerate markdown help so published docs reflect the new cmdlets/parameters.
|
/azp run |
|
Commenter does not have sufficient privileges for PR 29211 in repo Azure/azure-powershell |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…VirtualMachine_New.ps1 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
/azp run |
|
Commenter does not have sufficient privileges for PR 29211 in repo Azure/azure-powershell |
…tualMachine_New.ps1 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
/azp run |
|
Commenter does not have sufficient privileges for PR 29211 in repo Azure/azure-powershell |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| while(-not $mockingPath) { | ||
| $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | ||
| $currentPath = Split-Path -Path $currentPath -Parent | ||
| } |
There was a problem hiding this comment.
Same issue as the Suspend test: this loop may never terminate at filesystem root. Add a root detection/termination condition so CI doesn’t hang when the mocking script cannot be found.
| while(-not $mockingPath) { | |
| $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | |
| $currentPath = Split-Path -Path $currentPath -Parent | |
| } | |
| $mockingPath = $null | |
| while(-not $mockingPath) { | |
| $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File | |
| $parentPath = Split-Path -Path $currentPath -Parent | |
| if (-not $parentPath -or $parentPath -eq $currentPath) { | |
| break | |
| } | |
| $currentPath = $parentPath | |
| } | |
| if (-not $mockingPath) { | |
| throw "HttpPipelineMocking.ps1 could not be found starting from path '$PSScriptRoot'." | |
| } |
|
|
||
| Describe 'Suspend-AzStackHCIVMVirtualMachine' { | ||
| It 'ByResourceId' -skip { | ||
| { throw [System.NotImplementedException] } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'ByName' -skip { | ||
| { throw [System.NotImplementedException] } | Should -Not -Throw | ||
| } | ||
| } |
There was a problem hiding this comment.
These tests are currently skipped and don’t validate any cmdlet behavior (they just assert a NotImplementedException throw block is not executed). Since this PR introduces/exports the cmdlet, add at least one non-skipped test that exercises parameter binding and the internal call path (recorded/mocked), or remove these placeholders to avoid giving a false sense of coverage.
| Describe 'Suspend-AzStackHCIVMVirtualMachine' { | |
| It 'ByResourceId' -skip { | |
| { throw [System.NotImplementedException] } | Should -Not -Throw | |
| } | |
| It 'ByName' -skip { | |
| { throw [System.NotImplementedException] } | Should -Not -Throw | |
| } | |
| } |
| [System.Security.SecureString] | ||
| # AdminPassword - admin password (as SecureString) | ||
| ${AdminPassword}, |
There was a problem hiding this comment.
Changing AdminPassword from String to SecureString improves handling of sensitive data, but it is a breaking change for existing scripts that pass plain text. To reduce impact, consider either supporting a backward-compatible string parameter (deprecated) that is converted internally, or allowing PSCredential as the primary way to pass admin credentials.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| - Additional information about change #1 | ||
| --> | ||
| ## Upcoming Release | ||
| * Fixed missing export of `Save-AzStackHCIVMVirtualMachine` and `Suspend-AzStackHCIVMVirtualMachine` cmdlets by adding them to `FunctionsToExport` in the module manifest |
There was a problem hiding this comment.
The Upcoming Release entry is written in implementation terms (module manifest / FunctionsToExport) rather than user impact. Consider rewriting it from a user perspective (e.g., cmdlets are now available after importing the module) and add separate entries for the other user-facing changes in this PR (notably the parameter type changes to SecureString).
| Describe 'Suspend-AzStackHCIVMVirtualMachine' { | ||
| It 'ByResourceId' -skip { | ||
| { throw [System.NotImplementedException] } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'ByName' -skip { | ||
| { throw [System.NotImplementedException] } | Should -Not -Throw | ||
| } |
There was a problem hiding this comment.
These tests are currently skipped and only assert a NotImplementedException placeholder, so they don't validate the newly exported cmdlet behavior. Please replace the placeholders with recorded playback/live tests (or remove the test file until real coverage is available).
| [Parameter(ParameterSetName='GalleryImage', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Body')] | ||
| [System.String] | ||
| # Local path of image that the image should be created from. | ||
| # This parameter is required for non marketplace images. | ||
| [System.Security.SecureString] | ||
| # Local path of image that the image should be created from (as SecureString). | ||
| # This parameter is required for non marketplace images. | ||
| # Use: ConvertTo-SecureString -String "path\to\image.vhdx" -AsPlainText -Force | ||
| ${ImagePath}, |
There was a problem hiding this comment.
Changing -ImagePath from String to SecureString is a breaking change for existing scripts (PowerShell won't implicitly convert a string path to SecureString). If the goal is secret-handling, consider keeping -ImagePath as String (paths aren’t secrets) or supporting both types (e.g., an additional parameter or argument transformation), and regenerate help/examples accordingly.
| if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){ | ||
| Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop | ||
| } else { |
There was a problem hiding this comment.
The error message refers to the module as 'Az.StackHCIVm'. For consistency with the actual module name and user guidance, this should be 'Az.StackHCIVM'.
| if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){ | ||
| Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop | ||
| } else { |
There was a problem hiding this comment.
The error message refers to the module as 'Az.StackHCIVm'. For consistency with the actual module name and user guidance, this should be 'Az.StackHCIVM'.
| 'Restart-AzStackHCIVMVirtualMachine', | ||
| 'Save-AzStackHCIVMVirtualMachine', | ||
| 'Start-AzStackHCIVMVirtualMachine', | ||
| 'Stop-AzStackHCIVMVirtualMachine', 'Update-AzStackHCIVMImage', | ||
| 'Stop-AzStackHCIVMVirtualMachine', | ||
| 'Suspend-AzStackHCIVMVirtualMachine', | ||
| 'Update-AzStackHCIVMImage', |
There was a problem hiding this comment.
Now that these cmdlets are exported, the module help should be regenerated so users can discover and use them (e.g., add help markdown for Save-AzStackHCIVMVirtualMachine and Suspend-AzStackHCIVMVirtualMachine and update the module page if applicable).
| Describe 'Save-AzStackHCIVMVirtualMachine' { | ||
| It 'ByResourceId' -skip { | ||
| { throw [System.NotImplementedException] } | Should -Not -Throw | ||
| } | ||
|
|
||
| It 'ByName' -skip { | ||
| { throw [System.NotImplementedException] } | Should -Not -Throw | ||
| } |
There was a problem hiding this comment.
These tests are currently skipped and only assert a NotImplementedException placeholder, so they don't validate the newly exported cmdlet behavior. Please replace the placeholders with recorded playback/live tests (or remove the test file until real coverage is available).
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Commenter does not have sufficient privileges for PR 29211 in repo Azure/azure-powershell |
Description
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.