/// <summary> /// Retrieve a list of dsc compilation jobs. (see /// http://aka.ms/azureautomationsdk/compilationjoboperations for more /// information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Automation.IDscCompilationJobOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group /// </param> /// <param name='automationAccount'> /// Required. The automation account name. /// </param> /// <param name='parameters'> /// Optional. The parameters supplied to the list operation. /// </param> /// <returns> /// The response model for the list job operation. /// </returns> public static DscCompilationJobListResponse List(this IDscCompilationJobOperations operations, string resourceGroupName, string automationAccount, DscCompilationJobListParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IDscCompilationJobOperations)s).ListAsync(resourceGroupName, automationAccount, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Retrieve a list of dsc compilation jobs. (see /// http://aka.ms/azureautomationsdk/compilationjoboperations for more /// information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Automation.IDscCompilationJobOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group /// </param> /// <param name='automationAccount'> /// Required. The automation account name. /// </param> /// <param name='parameters'> /// Optional. The parameters supplied to the list operation. /// </param> /// <returns> /// The response model for the list job operation. /// </returns> public static Task <DscCompilationJobListResponse> ListAsync(this IDscCompilationJobOperations operations, string resourceGroupName, string automationAccount, DscCompilationJobListParameters parameters) { return(operations.ListAsync(resourceGroupName, automationAccount, parameters, CancellationToken.None)); }
private async Task checkCompilationJob(bool showPreviousJobOutput = false) { CancellationTokenSource cts = new CancellationTokenSource(); cts.CancelAfter(TIMEOUT_MS); if (showPreviousJobOutput) { DscCompilationJobListParameters jobParams = new DscCompilationJobListParameters(); jobParams.ConfigurationName = configurationName; // Look for jobs compiled in the last hour so we can show the status of the last job and also the paramaters jobParams.StartTime = DateTime.Now.AddMinutes(-60).ToString("o"); DscCompilationJobListResponse listResponse = await iseClient.automationManagementClient.CompilationJobs.ListAsync(iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, jobParams, cts.Token); if (listResponse.DscCompilationJobs.Count > 0) { lastJobID = listResponse.DscCompilationJobs.LastOrDefault().Properties.JobId; } else { return; } } DscCompilationJobGetResponse response = await iseClient.automationManagementClient.CompilationJobs.GetAsync(iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, lastJobID, cts.Token); // Set cancel output to false so we show the output of this job cancelOutput = false; JobDetails.FontWeight = FontWeights.Normal; JobDetails.Content = configurationName + " compilation job created at " + response.DscCompilationJob.Properties.CreationTime.LocalDateTime; JobDetails.Content += "\r\nLast refreshed at " + DateTime.Now; JobStatus.Content = response.DscCompilationJob.Properties.Status; if (response.DscCompilationJob.Properties.Status == "Failed") { updateJobOutputTextBlockWithException(response.DscCompilationJob.Properties.Exception); CompileConfigurationButton.IsEnabled = true; } else if (response.DscCompilationJob.Properties.Status == "Suspended") { updateJobOutputTextBlockWithException(response.DscCompilationJob.Properties.Exception); CompileConfigurationButton.IsEnabled = true; } else { cts = new CancellationTokenSource(); cts.CancelAfter(TIMEOUT_MS); JobStreamListResponse jslResponse = await iseClient.automationManagementClient.JobStreams.ListAsync(iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, lastJobID, jobStreamParams, cts.Token); if (jslResponse.JobStreams.Count > 0) { jobStreamParams.Time = jslResponse.JobStreams.Last().Properties.Time.UtcDateTime.ToString("o"); } /* Write out each stream's output */ foreach (JobStream stream in jslResponse.JobStreams) { // If cancelOutput is set to true, then we should break out and stop writing output if (cancelOutput) { break; } cts = new CancellationTokenSource(); cts.CancelAfter(TIMEOUT_MS); var jslStream = await iseClient.automationManagementClient.JobStreams.GetAsync(iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, lastJobID, stream.Properties.JobStreamId, cts.Token); // Current issue sending back previous streams so ensuring we have not already processed the job before outputing if ((processedStreamIDs.IndexOf(stream.Properties.JobStreamId) == -1)) { processedStreamIDs.Add(stream.Properties.JobStreamId); updateJobOutputTextBlock(jslStream); } } if (response.DscCompilationJob.Properties.Status == "Completed") { CompileConfigurationButton.IsEnabled = true; } else if (response.DscCompilationJob.Properties.Status == "Stopped") { CompileConfigurationButton.IsEnabled = true; } else if (!IsRetryStatusCode(response.StatusCode)) { CompileConfigurationButton.IsEnabled = true; } else { CompileConfigurationButton.IsEnabled = false; refreshTimer.Enabled = true; } } }