Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ public void SetAzureAutomationWebhookToDisabledSuccessful()
string name = "webhookName";

this.mockAutomationClient.Setup(
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false));
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false, "TestHybridGroup"));

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.Name = name;
this.cmdlet.IsEnabled = false;
this.cmdlet.Parameters = null;
this.cmdlet.RunOn = "TestHybridGroup";
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false),
f => f.UpdateWebhook(resourceGroupName, accountName, name, null, false, "TestHybridGroup"),
Times.Once());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Automation/Automation/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

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

## Version 1.3.6
* Fixed typo in Example 1 in reference documentation for `New-AzAutomationSoftwareUpdateConfiguration`
Expand Down
11 changes: 10 additions & 1 deletion src/Automation/Automation/Cmdlet/SetAzureAutomationWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public class SetAzureAutomationWebhook : AzureAutomationBaseCmdlet
HelpMessage = "The Runbook parameters name/value.")]
public IDictionary Parameters { get; set; }

/// <summary>
/// Gets or sets the optional hybrid agent friendly name upon which the runbook should be executed.
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = "Optional name of the hybrid agent which should execute the runbook")]
[Alias("HybridWorker")]
public string RunOn { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
Expand All @@ -60,7 +68,8 @@ protected override void AutomationProcessRecord()
this.AutomationAccountName,
this.Name,
this.Parameters,
this.IsEnabled);
this.IsEnabled,
this.RunOn);
this.WriteObject(updatedWebhook);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public Model.Webhook UpdateWebhook(
string automationAccountName,
string name,
IDictionary parameters,
bool? isEnabled)
bool? isEnabled,
string RunOn)
{
Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
Requires.Argument("AutomationAccountName", automationAccountName).NotNull();
Expand All @@ -168,6 +169,11 @@ public Model.Webhook UpdateWebhook(
webhookPatchParameters.Parameters =
this.ProcessRunbookParameters(resourceGroupName, automationAccountName, webhookModel.Runbook.Name, parameters);
}
if (RunOn != null)
{
webhookPatchParameters.RunOn = RunOn;

}
}

var webhook =
Expand Down
2 changes: 1 addition & 1 deletion src/Automation/Automation/Common/IAutomationPSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Model.Webhook CreateWebhook(

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

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

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

Expand Down
30 changes: 25 additions & 5 deletions src/Automation/Automation/help/Set-AzAutomationWebhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Modifies a webhook for an Automation runbook.
## SYNTAX

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

### Example 2
```powershell
PS C:\>Set-AzAutomationWebhook -Name "Webhook01" -ResourceGroup "ResourceGroup01" -AutomationAccountName "AutomationAccount01" -RunOn 'Windows'
```

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

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

This command updates the run on value for the webhook and forces the runbook to be run on an Azure runbook worker.

## PARAMETERS

### -AutomationAccountName
Expand Down Expand Up @@ -135,8 +140,23 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -RunOn
Optional name of the hybrid agent which should execute the runbook

```yaml
Type: System.String
Parameter Sets: (All)
Aliases: HybridWorker

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
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).
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).

## INPUTS

Expand Down