Skip to content
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

Fix the bug that warning message cannot be suppressed #13005

Merged
merged 9 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Monitor/Monitor/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

## Upcoming Release

## Version 2.1.1
* Fixed bug that always displayed warning Message when executing cmdlet based on MonitorCmdletBase [#12889]
Copy link
Member

Choose a reason for hiding this comment

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

My suggestion is

Fixed the bug that warning message cannot be suppressed. [#12889]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it


## Version 2.1.0
* Extended the parameter set in `Set-AzDiagnosticSetting` for separation of Logs and Metrics enablement [#12482]
* Fixed bug for `Add-AzMetricAlertRuleV2` when getting metric alert from pipeline
Expand Down
8 changes: 6 additions & 2 deletions src/Monitor/Monitor/MonitorCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ public override void ExecuteCmdlet()

try
{
WriteWarningWithTimestamp("*** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.");
WriteWarningWithTimestamp("*** The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.");
var isWarning = bool.Parse(System.Environment.GetEnvironmentVariable("SuppressAzurePowerShellBreakingChangeWarnings"));
Copy link
Member

Choose a reason for hiding this comment

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

shouldSuppress is more accurate.

Copy link
Member

Choose a reason for hiding this comment

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

What will happen if Environment is not set?

Copy link
Member

Choose a reason for hiding this comment

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

Test case is failed due to above reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it,thanks

if (!isWarning)
{
WriteWarningWithTimestamp("The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.");
WriteWarningWithTimestamp("The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.");
}
this.ProcessRecordInternal();
}
catch (AggregateException ex)
Expand Down