Simran Kaur
Simran Kaur

Reputation: 277

Schedule Azure Function according to weekday

I want to schedule my Azure Function as : 11:00 AM for Monday to Friday , 2:30 AM for Saturday & Sunday

How can I write cron expression for this?

Please help.

Upvotes: 2

Views: 1135

Answers (2)

Roberto Ramos
Roberto Ramos

Reputation: 603

You could try to use the Invoke Azure function with enviroment in your pipeline.

Here is an example:

enter image description here

Configure schedule in your pipeline in Azure devops. Here is an example:

    # YAML file in the main branch
schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
  branches:
    include:
    - master
- cron: "0 12 * * 0"
  displayName: Weekly Sunday build
  branches:
    include:
    - master

Upvotes: 0

Vova Bilyachat
Vova Bilyachat

Reputation: 19514

Unfortunately you would need to have two azure functions

public static void RunMonFriday([TimerTrigger("0 0 11 * * 1-5")]TimerInfo 
myTimer, ILogger log) { 
   // Call method to job
}
public static void RunSatSun([TimerTrigger("0 30 2 * * 6-7")]TimerInfo m
yTimer, ILogger log){
   // Call method to job
}

Upvotes: 4

Related Questions