Microsoft.Azure.Commands.Batch.Models.BatchClient.CreateJobSchedule C# (CSharp) Method

CreateJobSchedule() public method

Creates a new job schedule.
public CreateJobSchedule ( NewJobScheduleParameters parameters ) : void
parameters NewJobScheduleParameters The parameters to use when creating the job schedule.
return void
        public void CreateJobSchedule(NewJobScheduleParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            JobScheduleOperations jobScheduleOperations = parameters.Context.BatchOMClient.JobScheduleOperations;
            CloudJobSchedule jobSchedule = jobScheduleOperations.CreateJobSchedule();

            jobSchedule.Id = parameters.JobScheduleId;
            jobSchedule.DisplayName = parameters.DisplayName;

            if (parameters.Schedule != null)
            {
                jobSchedule.Schedule = parameters.Schedule.omObject;
            }

            if (parameters.JobSpecification != null)
            {
                Utils.Utils.JobSpecificationSyncCollections(parameters.JobSpecification);
                jobSchedule.JobSpecification = parameters.JobSpecification.omObject;
            }

            if (parameters.Metadata != null)
            {
                jobSchedule.Metadata = new List<MetadataItem>();
                foreach (DictionaryEntry d in parameters.Metadata)
                {
                    MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                    jobSchedule.Metadata.Add(metadata);
                }
            }
            WriteVerbose(string.Format(Resources.CreatingJobSchedule, parameters.JobScheduleId));
            jobSchedule.Commit(parameters.AdditionalBehaviors);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Creates a test job schedule for use in Scenario tests.
        /// </summary>
        public static void CreateTestJobSchedule(BatchController controller, BatchAccountContext context, string jobScheduleId, TimeSpan?recurrenceInterval)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();

            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient           client    = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSJobSpecification jobSpecification = new PSJobSpecification();

            jobSpecification.PoolInformation        = new PSPoolInformation();
            jobSpecification.PoolInformation.PoolId = SharedPool;
            PSSchedule schedule = new PSSchedule();

            if (recurrenceInterval != null)
            {
                schedule = new PSSchedule();
                schedule.RecurrenceInterval = recurrenceInterval;
            }

            NewJobScheduleParameters parameters = new NewJobScheduleParameters(context, jobScheduleId, behaviors)
            {
                JobSpecification = jobSpecification,
                Schedule         = schedule
            };

            client.CreateJobSchedule(parameters);
        }
All Usage Examples Of Microsoft.Azure.Commands.Batch.Models.BatchClient::CreateJobSchedule
BatchClient