Warm tip: This article is reproduced from stackoverflow.com, please click
azure-logic-apps

Stop Blob triggers running on weekends

发布于 2020-04-23 14:13:20

I have a logic app which is triggered when a blob is added or modified. It checks every few minutes. Given that logic apps are charged for each run of the Trigger (I think), how can I stop the Trigger running at weekends? I can't see anything on here

Questioner
AlHal
Viewed
38
Hury Shen 2020-02-10 19:10

You can create a azure timer trigger function with the cron expression to schedule the function run every Friday evening and call this api in the timer trigger function to disable your logic app.

For example, the cron expression could be:

59 59 23 * * Fri

Then create another timer trigger function with the cron expression to schedule the function run every Monday morning and call this api in the timer trigger function to enable your logic app.

For example, the cron expression could be:

0 0 0 * * Mon

Another solution:

You can add a condition after the blob trigger(before the actions which the logic will do), shown as below: enter image description here The expression of "dayOfWeek()" is:

dayOfWeek(utcNow())

In the response of dayOfWeek() method, Sunday --> 0, Monday --> 1.

So in the conditon above, most of the actions will just run on Monday to Friday. On Saturday and Sunday, you will just pay for the trigger but not for most of the actions in your logic app. But you need to pay attention to the time zone if use this solution. You an know more information about the pricing of logic app in this link.

By the way, I think the second solution may suit you better. Because in first solution we can't call the api easily in azure function, we have to get the access token(in implicit flow) before request the api.