I'm using Microsoft Azure Scheduler Management Library (https://www.nuget.org/packages/Microsoft.WindowsAzure.Management.Scheduler/) to schedule jobs in Azure Scheduler. So far, creating jobs by minute, hours and days is working fine.
My question is how to schedule a weekly job with specified days of the week. The code below results in exception with message "BadRequest: Cannot set days of month with recurrence unit 'Week'.". I can't see where I'm setting "days of month" as described in the exception. The Days collection is described as the "Days of the week that the job should execute on".
var result = _azureSchedulerClient.Jobs.CreateOrUpdate("My Job", new JobCreateOrUpdateParameters()
{
Action = _azureSchedulerJobAction,
StartTime = startDateTime,
Recurrence = new JobRecurrence()
{
Frequency = JobRecurrenceFrequency.Week,
Interval = 1,
EndTime = new DateTime(2014, 12, 31);
Schedule = new JobRecurrenceSchedule()
{
Days = new List<JobScheduleDay> { JobScheduleDay.Monday }
}
}
});
Has anyone been able to get a weekly schedule working? Thanks.
can you try this:
JobCreateOrUpdateResponse jobResp = schedClient.Jobs.CreateOrUpdate("testRecurrenceIssue", new JobCreateOrUpdateParameters
{
Action = new JobAction
{
Request = new JobHttpRequest { Uri = new Uri("http://www.bing.com"), Method = "GET" },
},
Recurrence = new JobRecurrence
{
Frequency = JobRecurrenceFrequency.Week,
Schedule = new JobRecurrenceSchedule
{
Days = new List<JobScheduleDay> { JobScheduleDay.Monday},
Hours = null,
Minutes = null,
MonthDays = null,
MonthlyOccurrences = null,
Months = null
}
}
});