2016-06-23 5 views
0

Ich verwende Azure Automation Management 2.0.1. Ich kann die Start-Methode für Runbooks nicht finden, um ein Runbook auszuführen. Wie dies mit 2.0.1Azure Automation Managment kann Runbook nicht ausführen

var client = new Microsoft.Azure.Management.Automation.AutomationManagementClient(new CertificateCloudCredentials(subscriptionId, cert)); 
var ct = new CancellationToken(); 

var content = await client.Runbooks.ListByNameAsync("MyAutomationAccountName", "MyRunbookName", ct); 

var firstOrDefault = content?.Runbooks.FirstOrDefault(); 
if (firstOrDefault != null) 
{ 
    var operation = client.Runbooks.Start("MyAutomationAccountName", new RunbookStartParameters(firstOrDefault.Id)); 
} 

Antwort

1

Sie benötigen die automationManagementClient.Jobs.Create

public static JobCreateResponse Create(
    this IJobOperations operations, 
    string resourceGroupName, 
    string automationAccount, 
    JobCreateParameters parameters 
) 

Sie eine vollständige Probe finden verwenden here dies der relevante Teil wäre -

private void JobStart_Click(object sender, RoutedEventArgs e) 
{ 
     // Check for runbook name 
     if (String.IsNullOrWhiteSpace(RunbookName.Text) || String.IsNullOrWhiteSpace(PublishState.Text)) throw new ArgumentNullException(RunbookName.Text); 

     // Create job create parameters 
     var jcparam = new JobCreateParameters 
     { 
      Properties = new JobCreateProperties 
      { 
       Runbook = new RunbookAssociationProperty 
       { 
        // associate the runbook name 
        Name = RunbookName.Text 
       }, 

       // pass parameters to runbook if any 
       Parameters = null 
      } 
     }; 

     // create runbook job. This gives back JobId 
     var job = automationManagementClient.Jobs.Create(this.automationAccountName, jcparam).Job; 

     JobGuid.Text = JobId.Text = job.Properties.JobId.ToString(); 

     Log.Text += (String.Format("\nJob Started for Runbook {0} , JobId {1}", RunbookName.Text, JobId.Text)); 
}