-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Az.ScVmm] Use ErrorAction Stop for Get Machine operations to fix exception being logged on console #28490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Az.ScVmm] Use ErrorAction Stop for Get Machine operations to fix exception being logged on console #28490
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.
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 improves error handling in the Az.ScVmm module by adding -ErrorAction Stop to Get-AzScVmmMachine operations to prevent expected exceptions from being logged to the console. The changes focus on suppressing unhelpful error messages that confuse users, while maintaining the same functionality.
- Added
-ErrorAction Stopto allGet-AzScVmmMachinecalls to properly handle expected exceptions - Enhanced error messages to include more context about the failure
- Fixed minor documentation capitalization issues and typos
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/ScVmm/ScVmm/ChangeLog.md | Added changelog entry for exception suppression fix |
| src/ScVmm/ScVmm.Autorest/custom/*.ps1 | Enhanced error handling with -ErrorAction Stop and improved error messages |
| src/ScVmm/ScVmm/help/*.md | Fixed capitalization in synopsis and description text |
| src/ScVmm/ScVmm.Autorest/docs/*.md | Fixed capitalization in synopsis and description text, corrected "MacAdders" typo |
| if ($null -eq $vmObj) { | ||
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable check is comparing $vmObj but the error message still refers to "Virtual Machine $vmName". The logic checks if $vmObj is null but should check if the VM object retrieval failed, not if $machineObj is null as in the original code.
| if ($null -eq $vmObj) { | |
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" | |
| throw "Failed to fetch Virtual Machine Object using MachineId '$($machineObj.Id)' for Virtual Machine '$vmName'" |
| if ($null -eq $vmObj) { | ||
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable check is comparing $vmObj but the error message still refers to "Virtual Machine $vmName". The logic checks if $vmObj is null but should check if the VM object retrieval failed, not if $machineObj is null as in the original code.
| if ($null -eq $vmObj) { | |
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" | |
| throw "Failed to fetch VM object for VM '$vmName' in Resource Group '$ResourceGroupName' (SubscriptionId '$SubscriptionId')" |
| if ($null -eq $vmObj) { | ||
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable check is comparing $vmObj but the error message still refers to "Virtual Machine $vmName". The logic checks if $vmObj is null but should check if the VM object retrieval failed, not if $machineObj is null as in the original code.
| if ($null -eq $vmObj) { | |
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" | |
| throw "Failed to fetch Virtual Machine Object for MachineId $($machineObj.Id) (VM Name: $vmName)" |
| if ($null -eq $vmObj) { | ||
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable check is comparing $vmObj but the error message still refers to "Virtual Machine $vmName". The logic checks if $vmObj is null but should check if the VM object retrieval failed, not if $machineObj is null as in the original code.
| if ($null -eq $vmObj) { | |
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" | |
| throw "Failed to fetch Virtual Machine Object for MachineId $($machineObj.Id) in Resource Group $ResourceGroupName (SubscriptionId $SubscriptionId)" |
| if ($null -eq $vmObj) { | ||
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable check is comparing $vmObj but the error message still refers to "Virtual Machine $vmName". The logic checks if $vmObj is null but should check if the VM object retrieval failed, not if $machineObj is null as in the original code.
| if ($null -eq $vmObj) { | |
| throw "Failed to fetch Virtual Machine Object for Virtual Machine $vmName" | |
| throw "Failed to fetch Virtual Machine Object for MachineId $($machineObj.Id) (VM Name: $vmName)" |
|
/azp run |
|
Commenter does not have sufficient privileges for PR 28490 in repo Azure/azure-powershell |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
please run |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
@VeryEarly, @isra-fel - Are there any additional steps required from me regarding the PR, and could you please share the timeline for when it will be rolled out to customers? |
please find timeline: https://github.com/Azure/azure-powershell/milestone/182 |
Description
Use
-ErrorAction StopforAz.ScVmm.internal\Get-AzScVmmMachineoperations to fix expected exception being logged on console.No change in API/Command.
The existing cmdlet works correctly, but the expected exception is printed to the console, which may confuse users into thinking the operation failed.
Before:

After:

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.