public static async Task<bool> isSourceControlEnabled(AutomationManagementClient automationClient, String resourceGroup, String automationAccount)
        {
            JobListParameters listParams = new JobListParameters();
            listParams.RunbookName = Constants.sourceControlRunbook;

            var response = await automationClient.Jobs.ListAsync(resourceGroup,
                    automationAccount, listParams, new System.Threading.CancellationToken());
            if (response.Jobs.Count > 0) return true;
            else return false;
        }
示例#2
0
        public IList<JobModelProxy> GetJobs(Guid runbookVersionId)
        {
            // Since Azure are so nice, not providing any IDs for our runbooks and instead
            // using the name to identify the runbooks (as contrary to SMA which uses GUIDs),
            // we need to query our backend context to retrieve the correct runbook based on
            // our genereated GUID
            var resource = Context.Runbooks.FirstOrDefault(r => (r.Tag as RunbookModelProxy).PublishedRunbookVersionID == runbookVersionId);

            if (resource == null) // no runbook found?
                return new List<JobModelProxy>();

            var runbook = resource.Tag as RunbookModelProxy;

            var jobList = new JobListParameters();
            jobList.RunbookName = runbook.RunbookName;

            var jobs = default(JobListResponse);
            var response = new List<JobModelProxy>();

            do
            {
                if (jobs != null)
                    jobs = _client.Jobs.ListNext(jobs.NextLink);
                else
                    jobs = _client.Jobs.List(_connectionData.AzureRMGroupName, _connectionData.AzureAutomationAccount, jobList);

                if (jobs.Jobs.Count > 0)
                {
                    var jobModels = jobs.Jobs.Select(j => new JobModelProxy(new Vendor.Azure.Job
                    {
                        JobID = j.Properties.JobId,
                        Id = j.Id,
                        WarningCount = 0,
                        ErrorCount = 0,
                        JobException = j.Properties.Exception,
                        CreationTime = j.Properties.CreationTime.DateTime,
                        EndTime = (j.Properties.EndTime.HasValue ? j.Properties.EndTime.Value.DateTime : default(DateTime?)),
                        JobStatus = j.Properties.Status,
                        JobStatusDeteails = j.Properties.StatusDetails,
                        LastModifiedTime = j.Properties.LastModifiedTime.DateTime,
                        StartTime = (j.Properties.StartTime.HasValue ? j.Properties.StartTime.Value.DateTime : default(DateTime?))
                    }, Context)).ToList();

                    response.AddRange(jobModels);
                }
            }
            while (jobs.NextLink != null);

            return response;
        }
 /// <summary>
 /// Retrieve a list of jobs.  (see
 /// http://aka.ms/azureautomationsdk/joboperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IJobOperations.
 /// </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<JobListResponse> ListAsync(this IJobOperations operations, string resourceGroupName, string automationAccount, JobListParameters parameters)
 {
     return operations.ListAsync(resourceGroupName, automationAccount, parameters, CancellationToken.None);
 }
 /// <summary>
 /// Retrieve a list of jobs.  (see
 /// http://aka.ms/azureautomationsdk/joboperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IJobOperations.
 /// </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 JobListResponse List(this IJobOperations operations, string resourceGroupName, string automationAccount, JobListParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IJobOperations)s).ListAsync(resourceGroupName, automationAccount, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Retrieve a list of jobs.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXXXX.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Automation.IJobOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the list operation.
 /// </param>
 /// <returns>
 /// The response model for the list job operation.
 /// </returns>
 public static Task<JobListResponse> ListFilteredByStartTimeEndTimeAsync(this IJobOperations operations, string automationAccount, JobListParameters parameters)
 {
     return operations.ListFilteredByStartTimeEndTimeAsync(automationAccount, parameters, CancellationToken.None);
 }