Skip to content

Commit 775d267

Browse files
authored
Added runOn parameter to Set-AzAutomationWebhook (#12677)
* Added runOn parameter to Set-AzAutomationWebhook * Updated help file * Updated changelog * Updated test file * Removed extra block and uncoded example
1 parent 7324352 commit 775d267

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed

src/Automation/Automation.Test/UnitTests/SetAzureAutomationWebhookTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,20 @@ public void SetAzureAutomationWebhookToDisabledSuccessful()
5050
string name = "webhookName";
5151

5252
this.mockAutomationClient.Setup(
53-
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false));
53+
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false, "TestHybridGroup"));
5454

5555
// Test
5656
this.cmdlet.ResourceGroupName = resourceGroupName;
5757
this.cmdlet.AutomationAccountName = accountName;
5858
this.cmdlet.Name = name;
5959
this.cmdlet.IsEnabled = false;
6060
this.cmdlet.Parameters = null;
61+
this.cmdlet.RunOn = "TestHybridGroup";
6162
this.cmdlet.ExecuteCmdlet();
6263

6364
// Assert
6465
this.mockAutomationClient.Verify(
65-
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false),
66+
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false, "TestHybridGroup"),
6667
Times.Once());
6768
}
6869
}

src/Automation/Automation/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
## Version 1.3.7
2323
* Fixed the issue that string with escape chars cannot be converted into json object.
24+
* Added a parameters to Set-AzAutomationWebhook to specify a Hybrid Worker Group
2425

2526
## Version 1.3.6
2627
* Fixed typo in Example 1 in reference documentation for `New-AzAutomationSoftwareUpdateConfiguration`

src/Automation/Automation/Cmdlet/SetAzureAutomationWebhook.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public class SetAzureAutomationWebhook : AzureAutomationBaseCmdlet
4949
HelpMessage = "The Runbook parameters name/value.")]
5050
public IDictionary Parameters { get; set; }
5151

52+
/// <summary>
53+
/// Gets or sets the optional hybrid agent friendly name upon which the runbook should be executed.
54+
/// </summary>
55+
[Parameter(Mandatory = false,
56+
HelpMessage = "Optional name of the hybrid agent which should execute the runbook")]
57+
[Alias("HybridWorker")]
58+
public string RunOn { get; set; }
59+
5260
/// <summary>
5361
/// Execute this cmdlet.
5462
/// </summary>
@@ -60,7 +68,8 @@ protected override void AutomationProcessRecord()
6068
this.AutomationAccountName,
6169
this.Name,
6270
this.Parameters,
63-
this.IsEnabled);
71+
this.IsEnabled,
72+
this.RunOn);
6473
this.WriteObject(updatedWebhook);
6574
}
6675
}

src/Automation/Automation/Common/AutomationPSClientWebhook.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ public Model.Webhook UpdateWebhook(
145145
string automationAccountName,
146146
string name,
147147
IDictionary parameters,
148-
bool? isEnabled)
148+
bool? isEnabled,
149+
string RunOn)
149150
{
150151
Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
151152
Requires.Argument("AutomationAccountName", automationAccountName).NotNull();
@@ -168,6 +169,11 @@ public Model.Webhook UpdateWebhook(
168169
webhookPatchParameters.Parameters =
169170
this.ProcessRunbookParameters(resourceGroupName, automationAccountName, webhookModel.Runbook.Name, parameters);
170171
}
172+
if (RunOn != null)
173+
{
174+
webhookPatchParameters.RunOn = RunOn;
175+
176+
}
171177
}
172178

173179
var webhook =

src/Automation/Automation/Common/IAutomationPSClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Model.Webhook CreateWebhook(
171171

172172
IEnumerable<Model.Webhook> ListWebhooks(string resourceGroupName, string automationAccountName, string runbooName, ref string nextLink);
173173

174-
Model.Webhook UpdateWebhook(string resourceGroupName, string automationAccountName, string name, IDictionary parameters, bool? isEnabled);
174+
Model.Webhook UpdateWebhook(string resourceGroupName, string automationAccountName, string name, IDictionary parameters, bool? isEnabled, string runOn);
175175

176176
void DeleteWebhook(string resourceGroupName, string automationAccountName, string name);
177177

src/Automation/Automation/help/Set-AzAutomationWebhook.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Modifies a webhook for an Automation runbook.
1414
## SYNTAX
1515

1616
```
17-
Set-AzAutomationWebhook [-Name] <String> [-IsEnabled] <Boolean> [[-Parameters] <IDictionary>]
17+
Set-AzAutomationWebhook [-Name] <String> [-IsEnabled] <Boolean> [[-Parameters] <IDictionary>] [-RunOn <String>]
1818
[-ResourceGroupName] <String> [-AutomationAccountName] <String> [-DefaultProfile <IAzureContextContainer>]
1919
[<CommonParameters>]
2020
```
@@ -32,14 +32,19 @@ PS C:\>Set-AzAutomationWebhook -Name "Webhook01" -ResourceGroup "ResourceGroup01
3232
This command disables a webhook named Webhook01 in the Automation account named AutomationAccount01.
3333

3434
### Example 2
35+
```powershell
36+
PS C:\>Set-AzAutomationWebhook -Name "Webhook01" -ResourceGroup "ResourceGroup01" -AutomationAccountName "AutomationAccount01" -RunOn 'Windows'
37+
```
3538

36-
Modifies a webhook for an Automation runbook. (autogenerated)
39+
This command sets the run on value for the webhook and forces the runbook to be run on a Hybrid Worker group called Windows.
3740

38-
<!-- Aladdin Generated Example -->
41+
### Example 3
3942
```powershell
40-
Set-AzAutomationWebhook -AutomationAccountName 'AutomationAccount01' -IsEnabled $false -Name 'Webhook01' -Parameters <IDictionary> -ResourceGroupName 'ResourceGroup01'
43+
PS C:\>Set-AzAutomationWebhook -Name "Webhook01" -ResourceGroup "ResourceGroup01" -AutomationAccountName "AutomationAccount01" -RunOn $null
4144
```
4245

46+
This command updates the run on value for the webhook and forces the runbook to be run on an Azure runbook worker.
47+
4348
## PARAMETERS
4449

4550
### -AutomationAccountName
@@ -135,8 +140,23 @@ Accept pipeline input: True (ByPropertyName)
135140
Accept wildcard characters: False
136141
```
137142
143+
### -RunOn
144+
Optional name of the hybrid agent which should execute the runbook
145+
146+
```yaml
147+
Type: System.String
148+
Parameter Sets: (All)
149+
Aliases: HybridWorker
150+
151+
Required: False
152+
Position: Named
153+
Default value: None
154+
Accept pipeline input: False
155+
Accept wildcard characters: False
156+
```
157+
138158
### CommonParameters
139-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
159+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
140160
141161
## INPUTS
142162

0 commit comments

Comments
 (0)