Skip to content

Commit

Permalink
Add an optional parameter called 'Location' to create/update action g…
Browse files Browse the repository at this point in the history
…roup cmdls (#18678)

* Task 14768687: AzNS || Powershell and SDK - Action Groups RP API's support for location

* Add help and change log

Co-authored-by: Thomas Pham <[email protected]>
  • Loading branch information
thomasp98296 and Thomas Pham authored Jun 28, 2022
1 parent 4a44c97 commit a2e29bb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
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

0 comments on commit a2e29bb

Please sign in to comment.