-
Notifications
You must be signed in to change notification settings - Fork 4k
Allow insights powershell to unselect data sinks in diagnosticsettings. #3452
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
Conversation
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.
@vcanaa a few comments
Also, make sure you update the help for Set-AzureRmDiagnosticSetting.md
(since you have changed the help in the dll-Help.xml file)
foreach (string category in this.Categories) | ||
{ | ||
LogSettings logSettings = properties.Logs.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase)); | ||
throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrains' parameter."); |
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.
@vcanaa why not create a parameter set where Enabled
is required if Timegrains
is used?
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.
I studied the parameter set and I didn't find a configuration that satisfies all the requirements. I decided to not use them.
{ | ||
if (!this.Enabled.HasValue) | ||
{ | ||
throw new ArgumentException("Parameter 'Enabled' is required by 'Categories' parameter."); |
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.
@vcanaa why not create a parameter set where Enabled
is required if Categories
is used?
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.
Parameter set doesn't cover all requirements.
{ | ||
logSettings.RetentionPolicy = retentionPolicy; | ||
} | ||
throw new ArgumentException("WorkspaceId and DisableWorkspace cannot be both present."); |
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.
@vcanaa use parameter sets to ensure that these parameters are mutually exclusive
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.
Parameter set doesn't cover all requirements.
{ | ||
metricSettings.RetentionPolicy = retentionPolicy; | ||
} | ||
throw new ArgumentException("ServiceBusId and DisableServiceBus cannot be both present."); |
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.
@vcanaa use parameter sets to ensure that these parameters are mutually exclusive
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.
Parameter set doesn't cover all requirements.
/// </summary> | ||
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Disable workspace")] | ||
[ValidateNotNullOrEmpty] | ||
public SwitchParameter DisableWorkspace { get; set; } |
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.
@vcanaa how do you handle the case of the three Disable parameters being used with the Enabled
parameter? If a user shouldn't be able to use all four together (or Enabled
with any combination of the three Disable parameters), then you should consider creating two parameters - one that has Enabled
, and another that has the three Disable parameters
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 powershell is supposed to offer a way to easily build the request. If the request ends up not being valid, we want to the server to validate and respond with proper message.
/// <summary> | ||
/// Gets or sets the switch for workspace parameter of the cmdlet | ||
/// </summary> | ||
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Disable workspace")] |
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.
@vcanaa please remove the ValueFromPipelineByPropertyName
attribute from the three SwitchParameter
parameters you have added
[ValidateNotNullOrEmpty] | ||
public bool Enabled { get; set; } | ||
public bool? Enabled { get; set; } |
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.
@vcanaa when can this be nullable?
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.
Customer can run the following
Set-AzureRmDiagnosticSettings -ResourceId <> -DisableStorage
@vcanaa please reopen this PR once you address the feedback and fix build failures. |
@azuresdkci retest this please |
@azuresdkci test this please |
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.
One minor change, otherwise, this looks good.
@@ -31,6 +32,11 @@ namespace Microsoft.Azure.Commands.Insights.Diagnostics | |||
[Cmdlet(VerbsCommon.Set, "AzureRmDiagnosticSetting"), OutputType(typeof(PSServiceDiagnosticSettings))] |
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.
Change cmdlet name to update and place an alias to Set (or vice-versa) Also, please note in upcoming breaking changes that the cmdlet name is changing to update: https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Insights/documentation/upcoming-breaking-changes.md
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.
Can we just leave the name as Set-DiagnsoticSettings? We are improving the api to support multiple diagnostic settings. After that we plan to retire this commandlet and have only Add-AzureRmDiagnosticSettings. I don't think we should change the name a command that is soon to be deprecated.
…s to Update-AzureRmDiagnosticSettings in the upcoming breaking changes doc
Description
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines