Azure Batch Job Schedule Configuration Issue

Stanley Ramakrishnan 40 Reputation points
2024-07-02T07:51:10.66+00:00

I've been working with the Python SDK to set up an Azure Batch job schedule, and I've encountered an issue with the scheduling configuration. Here’s the scenario:

I need to schedule a job to run only on Mondays and Fridays at 9 AM IST, which corresponds to 3:30 AM UTC. To achieve this, I've configured the weekDays attribute in the JSON structure to include "monday" and "friday". Additionally, I've set doNotRunUntil to "2024-07-03T03:30:00Z" for UTC conversion, and specified recurrenceInterval as "P1W" for weekly recurrence.

However, after creating the job schedule using the Python SDK, when I view it in the Azure portal UI, it shows the next run time as Wednesday at 9:00 AM UTC instead of Friday.

Here's the JSON structure I used for creating the job schedule:

{

"id": "your-job-schedule-id",

"schedule": {

    "startWindow": "PT1H",

    "doNotRunAfter": "2024-12-31T00:00:00Z",

    "doNotRunUntil": "2024-07-03T03:30:00Z",

    "recurrenceInterval": "P1W",

    "weekDays": ["monday", "friday"]

},

"jobSpecification": {

    "priority": 0,

    "usesTaskDependencies": false,

    "onAllTasksComplete": "terminatejob",

    "jobManagerTask": {

        "id": "job-manager",

        "commandLine": "cmd echo Hello World",

        "resourceFiles": [],

        "environmentSettings": [],

        "userIdentity": {

            "autoUser": {

                "scope": "task",

                "elevationLevel": "nonAdmin"

            }

        }

    },

    "taskFactory": {

        "type": "parametricSweep",

        "parameterSet": {

            "parameterType": "string",

            "values": ["monday", "friday"]

        },

        "repeatTask": {

            "id": "task-${AZ_BATCH_TASK_ID}",

            "commandLine": "cmd /c echo Hello, world!",

            "resourceFiles": [],

            "environmentSettings": [],

            "userIdentity": {

                "autoUser": {

                    "scope": "task",

                    "elevationLevel": "nonAdmin"

                }

            }

        }

    },

    "poolInfo": {

        "poolId": "your-pool-id"

    }

},

"constraints": {

    "weekDays": ["friday"]

}

}

Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
320 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 34,931 Reputation points Microsoft Employee
    2024-07-02T16:52:12.44+00:00

    @Stanley Ramakrishnan

    Reviewing the documentation, it seems that setting weekDays as part of the schedules is not mentioned and it is likely that this is causing an issue. You are also setting the doNotRunUntil as Wednesday. I suggest you set this as the day you want to start running, such as next Monday or Friday. You will need to create two separate schedules to run this on Monday and Friday.

    More information can be found on the Job Schedule - Add page as well as the Schedule Batch jobs for efficiency page.

    Hope this helps! Let me know if you have additional questions and I will do my best to assist.


    If you still have questions, please let us know in the "comments" and we would be happy to help you. Comment is the fastest way of notifying the experts.

    If the answer has been helpful, we appreciate hearing from you and would love to help others who may have the same question. Accepting answers helps increase visibility of this question for other members of the Microsoft Q&A community.

    Thank you for helping to improve Microsoft Q&A!

    User's image

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful