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

Add an optional parameter called 'Location' to create/update action group cmdls #18678

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 15 additions & 2 deletions src/Monitor/Monitor/ActionGroups/SetAzureRmActionGroupCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,23 @@ public class SetAzureRmActionGroupCommand : ManagementCmdletBase
public SwitchParameter DisableGroup { get; set; }

/// <summary>
/// Gets or sets the Tags of the activity log alert resource
/// Gets or sets the Tags of the action group resource
/// </summary>
[Parameter(ParameterSetName = ByPropertyName, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the action group resource")]
[Parameter(ParameterSetName = ByResourceId, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the action group resource")]
[Parameter(ParameterSetName = ByInputObject, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The tags of the action group resource")]
[ValidateNotNullOrEmpty]
public IDictionary<string, string> Tag { get; set; }

/// <summary>
/// Gets or sets the location of the action group resource
/// </summary>
[Parameter(ParameterSetName = ByPropertyName, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The location of the action group resource")]
[Parameter(ParameterSetName = ByResourceId, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The location of the action group resource")]
[Parameter(ParameterSetName = ByInputObject, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The location of the action group resource")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

/// <summary>
/// Gets or sets the resource id parameter.
/// </summary>
Expand Down Expand Up @@ -130,6 +139,10 @@ protected override void ProcessRecordInternal()
{
this.Tag = this.InputObject.Tags;
}
if (this.Location == null)
{
this.Location = this.InputObject.Location;
}
this.Receiver = new List<PSActionGroupReceiverBase>();
this.Receiver.AddRange(this.InputObject.EmailReceivers);
this.Receiver.AddRange(this.InputObject.SmsReceivers);
Expand Down Expand Up @@ -224,7 +237,7 @@ protected override void ProcessRecordInternal()

ActionGroupResource actionGroup = new ActionGroupResource
{
Location = "Global",
Location = this.Location ?? "Global",
GroupShortName = this.ShortName,
Enabled = !this.DisableGroup.IsPresent || !this.DisableGroup,
Tags = this.Tag,
Expand Down
2 changes: 2 additions & 0 deletions src/Monitor/Monitor/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
-->

## Upcoming Release
## Version 3.0.2
* Added optional parameter `Location` for Adding/Update action group cmdlet

## Version 3.0.1
* Fixed an issue where users could not correctly ignore warning messages after setting environment variables [#17013]
Expand Down
8 changes: 6 additions & 2 deletions src/Monitor/Monitor/help/Set-AzActionGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Creates a new or updates an existing action group.
```
Set-AzActionGroup -ResourceGroupName <String> -Name <String> -ShortName <String>
-Receiver <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Insights.OutputClasses.PSActionGroupReceiverBase]>
[-DisableGroup] [-Tag <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-DisableGroup] [-Tag <System.Collections.Generic.IDictionary`2[System.String,System.String]>] [-Location <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

Expand All @@ -26,12 +26,13 @@ Set-AzActionGroup -ResourceGroupName <String> -Name <String> -ShortName <String>
Set-AzActionGroup -ShortName <String>
-Receiver <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Insights.OutputClasses.PSActionGroupReceiverBase]>
[-DisableGroup] [-Tag <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-Location <String>]
-ResourceId <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ByInputObject
```
Set-AzActionGroup [-ShortName <String>] [-DisableGroup]
Set-AzActionGroup [-ShortName <String>] [-DisableGroup] [-Location <String>]
[-Tag <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
-InputObject <PSActionGroupResource> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Expand Down Expand Up @@ -201,6 +202,9 @@ Accept wildcard characters: False
### -Tag
The tags of the action group resource

### -Location
The location of the action group resource

```yaml
Type: System.Collections.Generic.IDictionary`2[System.String,System.String]
Parameter Sets: ByPropertyName, ByResourceId
Expand Down