1
votes

I have an azure webjob that needs to be called every 5 mins with the argument "IsFullImport=false", and every Saturday at 12am with argument "IsFullImport=true". Currently I have 2 Logic Apps with reoccurrence set up that point to the same webjob, 1 runs every 5 mins and the other every Saturday at 12am.

The problem is if the every 5 min Logic App is running at the same time the Saturday at 12am one runs, I'll get a 409 error saying "conflict the WebJob is already running". Once the 12am one errors it won't try again until the next Saturday. I looked into retry policy and it doesn't apply to error 409. I also looked into concurrency policy and it seems that only applies to instances of the same Logic App, not 2 different Logic Apps. Is there a way I can get the Saturday 12am Logic App to retry if webjob is already running or maybe have one Logic App with 2 different schedules and api call?

Examples of Api calls:

Called Every 5 Mins:

https://mysite.scm.azurewebsites.net/api/triggeredwebjobs/MyJob/run?arguments="IsFullImport=false"

Called Every Saturday at 12am: https://mysite.scm.azurewebsites.net/api/triggeredwebjobs/MyJob/run?arguments="IsFullImport=true"

1

1 Answers

1
votes

For this requirement, we can implement it in one logic app theoretically. But if we do it in one logic app, I think we need to deal with many problems about time around Saturday 12am. So I suggest you to do it in separate logic apps and provide a solution below for your reference:

1. In your recurrence every Saturday 12am logic app, initialize a variable named statusCode and set its value as 409.

enter image description here

2. Then add "Until" loop in your logic app and set the condition as statusCode not equal to 409.

enter image description here

3. In "Until" loop, add a "HTTP" action to request your api https://mysite.scm.azurewebsites.net/api/triggeredwebjobs/MyJob/run?arguments="IsFullImport=true and use "Set variable" action to set the value of statusCode as outputs('HTTP')?['statusCode']

enter image description here

4. This step is critical, click ... button of "Set variable" action, then click "Configure run after".

enter image description here

Check both is successful and has failed options. enter image description here

5. After that, your logic app will continue to request the api until the statusCode is not equal to 409