/// <summary>
 /// Job history tracks the updates and executions of a job.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.WindowsAzure.Scheduler.IJobOperations.
 /// </param>
 /// <param name='jobId'>
 /// Id of the job to get the history of.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Get Job History operation.
 /// </param>
 /// <returns>
 /// The Get Job History operation response.
 /// </returns>
 public static Task <JobGetHistoryResponse> GetHistoryAsync(this IJobOperations operations, string jobId, JobGetHistoryParameters parameters)
 {
     return(operations.GetHistoryAsync(jobId, parameters, CancellationToken.None));
 }
 /// <summary>
 /// Job history tracks the updates and executions of a job.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.WindowsAzure.Scheduler.IJobOperations.
 /// </param>
 /// <param name='jobId'>
 /// Id of the job to get the history of.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Get Job History operation.
 /// </param>
 /// <returns>
 /// The Get Job History operation response.
 /// </returns>
 public static JobGetHistoryResponse GetHistory(this IJobOperations operations, string jobId, JobGetHistoryParameters parameters)
 {
     try
     {
         return(operations.GetHistoryAsync(jobId, parameters).Result);
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
        // retrieve the windows azure managment certificate from current user
        public ApprenticeShipSchedular()
        {
            var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);

            store.Open(OpenFlags.ReadWrite);
            var certificate = store.Certificates.Find(X509FindType.FindByThumbprint, "CA4716F85EC0962E2B69BB7D626CC16B924E550D", false)[0];

            store.Close();
            //
            // create management credencials and cloud service management client
            var credentials        = new CertificateCloudCredentials("bd27a79c-de25-4097-a874-3bb35f2b926a", certificate);
            var cloudServiceMgmCli = new CloudServiceManagementClient(credentials);

            // create cloud service
            var cloudServiceCreateParameters = new CloudServiceCreateParameters
            {
                Description = "sfaarmscheduler",
                Email       = "*****@*****.**",
                GeoRegion   = "West Europe",
                Label       = "sfaarmscheduler"
            };
            var cloudService = cloudServiceMgmCli.CloudServices.Create("sfaarmscheduler", cloudServiceCreateParameters);
            // create job collection
            var schedulerMgmCli = new SchedulerManagementClient(credentials);
            var jobCollectionIntrinsicSettings = new JobCollectionIntrinsicSettings
            {
                //Add Credentials for X.509
                Plan  = JobCollectionPlan.Free,
                Quota = new JobCollectionQuota
                {
                    MaxJobCount      = 5,
                    MaxJobOccurrence = 1,
                    MaxRecurrence    = new JobCollectionMaxRecurrence
                    {
                        Frequency = JobCollectionRecurrenceFrequency.Hour,
                        Interval  = 1
                    }
                }
            };
            var jobCollectionCreateParameters = new JobCollectionCreateParameters
            {
                IntrinsicSettings = jobCollectionIntrinsicSettings,
                Label             = "sfajobcollection"
            };
            var jobCollectionCreateResponse =
                schedulerMgmCli.JobCollections.Create("sfaarmscheduler", "sfajobcollection", jobCollectionCreateParameters);

            var schedulerClient = new SchedulerClient("sfaarmscheduler", "sfajobcollection", credentials);
            var jobAction       = new JobAction
            {
                Type         = JobActionType.StorageQueue,
                QueueMessage = new JobQueueMessage()
                {
                    Message = "test", QueueName = "vacancysummaryqueueitem", SasToken = "?sv=2017-04-17&ss=bfqt&srt=sco&sp=rwdlacup&se=2017-09-01T21:58:06Z&st=2017-09-01T13:58:06Z&spr=https&sig=r0u1A01ytcN213lsWO47Td7DUaU7lo3aQTPNTCrHRxU%3D", StorageAccountName = "sfabetastorage"
                }
                //Request = new JobHttpRequest
                //{
                //    Uri = new Uri("http://blog.shaunxu.me"),
                //    Method = "GET"
                //}
            };
            var jobRecurrence = new JobRecurrence
            {
                Frequency = JobRecurrenceFrequency.Hour,
                Interval  = 1
            };
            var jobCreateOrUpdateParameters = new JobCreateOrUpdateParameters
            {
                Action     = jobAction,
                Recurrence = jobRecurrence
            };
            var jobCreateResponse = schedulerClient.Jobs.CreateOrUpdate("poll_blog", jobCreateOrUpdateParameters);

            var jobGetHistoryParameters = new JobGetHistoryParameters
            {
                Skip = 0,
                Top  = 100
            };
            var history = schedulerClient.Jobs.GetHistory("poll_blog", jobGetHistoryParameters);

            foreach (var action in history)
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", action.Status, action.Message, action.RetryCount,
                                  action.RepeatCount, action.Timestamp);
            }
        }
Exemple #4
0
 /// <summary>
 /// Get the execution history of a Job.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.WindowsAzure.Scheduler.IJobOperations.
 /// </param>
 /// <param name='jobId'>
 /// Required. Id of the job to get the history of.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Get Job History operation.
 /// </param>
 /// <returns>
 /// The Get Job History operation response.
 /// </returns>
 public static JobGetHistoryResponse GetHistory(this IJobOperations operations, string jobId, JobGetHistoryParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IJobOperations)s).GetHistoryAsync(jobId, parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemple #5
0
        // retrieve the windows azure managment certificate from current user
        public Schedular()
        {
            var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);

            store.Open(OpenFlags.ReadWrite);
            var certificate = store.Certificates.Find(X509FindType.FindByThumbprint, "<ThumbPrint>", false)[0];

            store.Close();
            //
            // create management credencials and cloud service management client
            var credentials        = new CertificateCloudCredentials("8cb918af-59d0-4b24-893c-15661d048f16", certificate);
            var cloudServiceMgmCli = new CloudServiceManagementClient(credentials);

            // create cloud service
            var cloudServiceCreateParameters = new CloudServiceCreateParameters()
            {
                Description = "schedulerdemo1",
                Email       = "microsoft.com",
                GeoRegion   = "Southeast Asia",
                Label       = "schedulerdemo1"
            };
            var cloudService = cloudServiceMgmCli.CloudServices.Create("schedulerdemo1", cloudServiceCreateParameters);
            // create job collection
            var schedulerMgmCli = new SchedulerManagementClient(credentials);
            var jobCollectionIntrinsicSettings = new JobCollectionIntrinsicSettings()
            {
                Plan  = JobCollectionPlan.Free,
                Quota = new JobCollectionQuota()
                {
                    MaxJobCount      = 5,
                    MaxJobOccurrence = 1,
                    MaxRecurrence    = new JobCollectionMaxRecurrence()
                    {
                        Frequency = JobCollectionRecurrenceFrequency.Hour,
                        Interval  = 1
                    }
                }
            };
            var jobCollectionCreateParameters = new JobCollectionCreateParameters()
            {
                IntrinsicSettings = jobCollectionIntrinsicSettings,
                Label             = "jc1"
            };
            var jobCollectionCreateResponse = schedulerMgmCli.JobCollections.Create("schedulerdemo1", "jc1", jobCollectionCreateParameters);

            var schedulerClient = new SchedulerClient("schedulerdemo1", "jc1", credentials);
            var jobAction       = new JobAction()
            {
                Type    = JobActionType.Http,
                Request = new JobHttpRequest()
                {
                    Uri    = new Uri("http://blog.shaunxu.me"),
                    Method = "GET"
                }
            };
            var jobRecurrence = new JobRecurrence()
            {
                Frequency = JobRecurrenceFrequency.Hour,
                Interval  = 1
            };
            var jobCreateOrUpdateParameters = new JobCreateOrUpdateParameters()
            {
                Action     = jobAction,
                Recurrence = jobRecurrence
            };
            var jobCreateResponse = schedulerClient.Jobs.CreateOrUpdate("poll_blog", jobCreateOrUpdateParameters);

            var jobGetHistoryParameters = new JobGetHistoryParameters()
            {
                Skip = 0,
                Top  = 100
            };
            var history = schedulerClient.Jobs.GetHistory("poll_blog", jobGetHistoryParameters);

            foreach (var action in history)
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", action.Status, action.Message, action.RetryCount, action.RepeatCount, action.Timestamp);
            }
        }