public Model.Webhook CreateWebhook( string resourceGroupName, string automationAccountName, string name, string runbookName, bool isEnabled, DateTimeOffset expiryTime, IDictionary runbookParameters, string runOn) { Requires.Argument("ResourceGroupName", resourceGroupName).NotNull(); Requires.Argument("AutomationAccountName", automationAccountName).NotNull(); using (var request = new RequestSettings(this.automationManagementClient)) { var rbAssociationProperty = new RunbookAssociationProperty { Name = runbookName }; var createOrUpdateProperties = new WebhookCreateOrUpdateProperties { IsEnabled = isEnabled, ExpiryTime = expiryTime, Runbook = rbAssociationProperty, Uri = this.automationManagementClient .Webhooks.GenerateUri( resourceGroupName, automationAccountName).Uri, RunOn = runOn }; if (runbookParameters != null) { createOrUpdateProperties.Parameters = this.ProcessRunbookParameters(resourceGroupName, automationAccountName, runbookName, runbookParameters); } var webhookCreateOrUpdateParameters = new WebhookCreateOrUpdateParameters( name, createOrUpdateProperties); var webhook = this.automationManagementClient.Webhooks.CreateOrUpdate( resourceGroupName, automationAccountName, webhookCreateOrUpdateParameters).Webhook; return(new Model.Webhook( resourceGroupName, automationAccountName, webhook, webhookCreateOrUpdateParameters.Properties.Uri)); } }
/// <summary> /// Invokes the specified runbook. /// </summary> /// <param name="resourceGroupName">Name of the resource group.</param> /// <param name="automationAccount">The automation account.</param> /// <param name="runbookName">Name of the runbook.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// automationAccount /// or /// resourceGroupName /// or /// runbookName /// </exception> public async Task InvokeRunbookAsync(string resourceGroupName, string automationAccount, string runbookName) { JobCreateParameters jcp; RunbookAssociationProperty rap; if (string.IsNullOrEmpty(automationAccount)) { throw new ArgumentNullException(nameof(automationAccount)); } if (string.IsNullOrEmpty(runbookName)) { throw new ArgumentNullException(nameof(runbookName)); } if (string.IsNullOrEmpty(resourceGroupName)) { throw new ArgumentNullException(nameof(resourceGroupName)); } try { rap = new RunbookAssociationProperty() { Name = runbookName }; jcp = new JobCreateParameters(new JobCreateProperties(rap) { Parameters = null }); await Client.Jobs.CreateAsync(resourceGroupName, automationAccount, jcp).ConfigureAwait(false); } finally { rap = null; jcp = null; } }