Azure logical app get first date of month - azure

I have an Azure Logical app, I want to get the first date of the month two days ago.
For example:
1. If today is '2022-08-01' then two days ago was '2022-07-29', I want to get '2022-07-01' as result
2. If today is '2022-08-02' then two days ago was '2022-07-31', I want to get '2022-07-01' as result
3. If today is '2022-08-03' then two days ago was '2022-08-01', I want to get '2022-08-01' as result
I already know I can get date for two days ago using "#addDays(utcNow(), -2, 'yyyy-MM-dd')" but I basically need first date of the month this date belongs to

You can use startOfMonth() function after calculating for 2 days ago date in order to achieve your requirement. Below is my Logic App flow.
RESULTS:
You can use the below code-view to reproduce the same in your environment.
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "#startOfMonth(outputs('Compose_2'),'yyyy-MM-dd')",
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Compose_2": {
"inputs": "#addDays(variables('Date'), -2, 'yyyy-MM-dd')",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Compose"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Date",
"type": "string",
"value": "2022-08-03"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}

Related

retrieve values from an json array in azure logic app

what will be the easiest way to retrive the "HydraulicPressure" and "FailedPickupsLastHr" values from the below json in logic app?
{
"variables": [
{
"name": "sensorarray",
"type": "String",
"value": "{\"ContentData\":{\"applicationId\":\"0db2345\",\"deviceId\":\"178\",\"enqueuedTime\":\"2022-09-17T14:27:22.386Z\",\"enrichments\":{},\"messageSource\":\"properties\",\"messageType\":\"devicePropertyReportedChange\",\"properties\":[{\"name\":\"FailedPickupsLastHr\",\"value\":42},{\"name\":\"HydraulicPressure\",\"value\":30.863390107917837}],\"schema\":\"default#v1\",\"templateId\":\"dtmi:z\"},\"Properties\":{\"iotcentral-application-id\":\"05\",\"iotcentral-message-source\":\"properties\",\"iotcentral-message-type\":\"devicePropertyReportedChange\",\"iotcentral-device-id\":\"1q9hn5l4xcl\",\"x-opt-sequence-number\":5663,\"x-opt-offset\":\"5307784\",\"x-opt-enqueued-time\":\"2022-09-17T14:27:28.046Z\",\"message-id\":{\"EncodeSize\":38},\"group-sequence\":0},\"SystemProperties\":{\"EnqueuedTimeUtc\":\"2022-09-17T14:27:28.046Z\",\"Offset\":\"5307784\",\"PartitionKey\":null,\"SequenceNumber\":5663}}"
}
]
}
Load this definition as a new LogicApp into your tenant ...
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Initialize_Failed_Pickups_Last_Hr": {
"inputs": {
"variables": [
{
"name": "FailedPickupsLastHr",
"type": "integer",
"value": "#variables('Object')['ContentData']['properties'][0]['value']"
}
]
},
"runAfter": {
"Initialize_Hydraulic_Pressure": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_Hydraulic_Pressure": {
"inputs": {
"variables": [
{
"name": "HydraulicPressure",
"type": "string",
"value": "#{variables('Object')['ContentData']['properties'][1]['value']}"
}
]
},
"runAfter": {
"Initialize_Object": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_Object": {
"inputs": {
"variables": [
{
"name": "Object",
"type": "object",
"value": "#JSON(variables('Payload'))"
}
]
},
"runAfter": {
"Initialize_Payload": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_Payload": {
"inputs": {
"variables": [
{
"name": "Payload",
"type": "string",
"value": "{\"ContentData\":{\"applicationId\":\"0db2345\",\"deviceId\":\"178\",\"enqueuedTime\":\"2022-09-17T14:27:22.386Z\",\"enrichments\":{},\"messageSource\":\"properties\",\"messageType\":\"devicePropertyReportedChange\",\"properties\":[{\"name\":\"FailedPickupsLastHr\",\"value\":42},{\"name\":\"HydraulicPressure\",\"value\":30.863390107917837}],\"schema\":\"default#v1\",\"templateId\":\"dtmi:z\"},\"Properties\":{\"iotcentral-application-id\":\"05\",\"iotcentral-message-source\":\"properties\",\"iotcentral-message-type\":\"devicePropertyReportedChange\",\"iotcentral-device-id\":\"1q9hn5l4xcl\",\"x-opt-sequence-number\":5663,\"x-opt-offset\":\"5307784\",\"x-opt-enqueued-time\":\"2022-09-17T14:27:28.046Z\",\"message-id\":{\"EncodeSize\":38},\"group-sequence\":0},\"SystemProperties\":{\"EnqueuedTimeUtc\":\"2022-09-17T14:27:28.046Z\",\"Offset\":\"5307784\",\"PartitionKey\":null,\"SequenceNumber\":5663}}"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"ParameterTest1": {
"defaultValue": "\"\"",
"type": "String"
}
},
"triggers": {
"manual": {
"inputs": {
"method": "GET",
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
It will give you my answer in full and show you how to get to the values you're after.
The basic steps are ...
Initialize the initial JSON you have as a string.
Then convert that string to an object using the json expression
The last two steps involve expressions to extract the values you're after.
Basically, you need to parse the string value to an object and then evaluate it.
I have reproduced in my environment, you can similarly do it for your json array as below:
Firstly, select initialize variable step and then set it with below json example :
[{
"variables":
{
"name": "sensorarray",
"type": "String"
}
}]
Then, select the SELECT step
And then select the varaible you want from array and then get it with using item as below:
Output:
Try to update your array as the given example and try the above steps you will get the output as above.

How do I parse text by line in an Azure Logic App?

I've got a Logic App that reads in an email from a form submission. Unfortunately, I only have access to the email and not where the form results are stored, so I currently have the Logic App set up to pull in the email and convert it to text.
If it was just one field, I assume I could just grab it all, throw it in a variable and split it to get what I need, but I'm not sure how to do this with multiple lines.
The emails always come in with this format:
---
Date: 08/18/2022
Time: 09:30:00
Requestor Name: Robert Bobson
Requestor Email: bob#companyname.com
Requestor Phone Number: 800-867-5309
Site Name: CompanyName
Site Number: 123456789
---
Am I able to set a line index and then grab everything on that line and then split it before assigning it to a variable? Is this going to require RegEx or is there a workaround or expression in Logic Apps that will handle this?
Thank you in advance!
You can achieve your requirement using expressions.
First, try removing the extra lines from the given email. below is the expression I'm using to achieve the same.
split(outputs('Compose'),'\n\n')
The above expression results in:
Am I able to set a line index and then grab everything on that line and then split it before assigning it to a variable?
yes, This is possible using the below expression
outputs('Compose_2')?[0] gives the Date
outputs('Compose_2')?[1] gives the Time
...
RESULTS:
Alternatively, You can convert the string into Parsable Json and then Parse it through Parse JSON Action. Below is the flow of my Logic App
In the above step I'm extracting the values on both left and right sides and storing them into a variable. You can use either of slice or substring functions to extract the values.
In the next step I'm trying to Parse the values through Parse JSON action.
RESULTS:
You can test the same using below code view in your logicapp
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "Date: 08/18/2022\n\nTime: 09:30:00\n\nRequestor Name: Robert Bobson\n\nRequestor Email: bob#companyname.com\n\nRequestor Phone Number: 800-867-5309\n\nSite Name: CompanyName\n\nSite Number: 123456789",
"runAfter": {},
"type": "Compose"
},
"Compose_2": {
"inputs": "#split(outputs('Compose'),'\n\n')",
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Compose"
},
"Compose_3": {
"inputs": "#body('Parse_JSON')?['Site Name']",
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Compose"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "length",
"type": "integer"
}
]
},
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_variable_2": {
"inputs": {
"variables": [
{
"name": "Json",
"type": "string"
}
]
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "#concat('{',substring(variables('Json'),0,sub(length(variables('Json')),1)),'}')",
"schema": {
"properties": {
"Date": {
"type": "string"
},
"Requestor Email": {
"type": "string"
},
"Requestor Name": {
"type": "string"
},
"Requestor Phone Number": {
"type": "string"
},
"Site Name": {
"type": "string"
},
"Site Number": {
"type": "string"
},
"Time": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {
"Until": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Until": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "Json",
"value": "#{outputs('Current_Object')},"
},
"runAfter": {
"Current_Object": [
"Succeeded"
]
},
"type": "AppendToStringVariable"
},
"Current_Object": {
"inputs": "\"#{substring(outputs('Compose_2')?[variables('length')],0,indexOf(outputs('Compose_2')?[variables('length')],':'))}\":\"#{slice(outputs('Compose_2')?[variables('length')],add(indexOf(outputs('Compose_2')?[variables('length')],':'),2),length(outputs('Compose_2')?[variables('length')]))}\"",
"runAfter": {},
"type": "Compose"
},
"Increment_variable": {
"inputs": {
"name": "length",
"value": 1
},
"runAfter": {
"Append_to_string_variable": [
"Succeeded"
]
},
"type": "IncrementVariable"
}
},
"expression": "#equals(variables('length'), length(outputs('Compose_2')))",
"limit": {
"count": 60,
"timeout": "PT1H"
},
"runAfter": {
"Initialize_variable_2": [
"Succeeded"
]
},
"type": "Until"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
You can Convert the email body using "Html To Text" action and then assign it to an array variable by using the split expression for any delimiter.

Azure Logic App HTTP Action step - dynamically get endOfDate date

i have an azure logic app with recurrence that will call api endpoint every midnight, im passing in two date properties in my request body that will include start of day and end of day.
Logic app has expression startOfDay() however they dont have endOfDay(), how can I dynamically get end of day in UTC format like startOfDay() does?
Thanks
this is how my request body looks like but its also complaining about #startOfDay()
{
"organizationId": 'f41186b0-7f09-42c5-8a9d-81a2ad2b0e61',
"attemptedDeliveries": true,
"cancelDateStart": #{startOfDay()},
"cancelDateEnd": ""
}
There is no direct expression for endOfDay but one of the workarounds is to addToTime and 'subtractFromTime' from startOfDay to get the endOfDay. Consider I'm taking the timestamp to be UtcNow() and to calculate the endOfDay I'm using the below expression.
subtractFromTime(addToTime(outputs('startOfDay'),1,'Day','o'),1,'Second','yyyy-MM-ddTHH:mm:ss')
I'm using Parse Json in order to retrieve the inner Json details for future use. By doing this, you can have a custom JSON created using Compose() connector.
Result:-
Codeview
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": {
"attemptedDeliveries": "#body('Parse_JSON')?['attemptedDeliveries']",
"cancelDateEnd": "#{outputs('endOfDay')}",
"cancelDateStart": "#{outputs('startOfDay')}",
"organizationId": "#{body('Parse_JSON')?['organizationId']}"
},
"runAfter": {
"endOfDay": [
"Succeeded"
]
},
"type": "Compose"
},
"Parse_JSON": {
"inputs": {
"content": "#triggerBody()",
"schema": {
"properties": {
"attemptedDeliveries": {
"type": "boolean"
},
"cancelDateEnd": {
"type": "string"
},
"cancelDateStart": {
"type": "string"
},
"organizationId": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
},
"endOfDay": {
"inputs": "#subtractFromTime(addToTime(startOfDay(utcNow()),1,'Day','o'),1,'Second','yyyy-MM-ddTHH:mm:ss')",
"runAfter": {
"startOfDay": [
"Succeeded"
]
},
"type": "Compose"
},
"startOfDay": {
"inputs": "#startOfDay(utcNow(),'yyyy-MM-ddTHH:mm:ss')",
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Compose"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
Here is the json that I'm receiving from my body of Http trigger
{
"organizationId": "f41186b0-7f09-42c5-8a9d-81a2ad2b0e61",
"attemptedDeliveries": true,
"cancelDateStart": "",
"cancelDateEnd": ""
}
Updated Answer
After the follow up here my logic app
Result:
Codeview
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"endOfDay": {
"inputs": "#subtractFromTime(addToTime(startOfDay(utcNow()),1,'Day','o'),1,'Second','yyyy-MM-ddTHH:mm:ss')",
"runAfter": {
"startOfDay": [
"Succeeded"
]
},
"type": "Compose"
},
"startOfDay": {
"inputs": "#startOfDay(utcNow(),'yyyy-MM-ddTHH:mm:ss')",
"runAfter": {},
"type": "Compose"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Second",
"interval": 30
},
"recurrence": {
"frequency": "Second",
"interval": 30
},
"type": "Recurrence"
}
}
},
"parameters": {}
}
After endOfDay connector you can add 4 parallel HTTP triggers and add logic to it.
REFERENCES: Reference guide to workflow expression functions in Azure Logic Apps and Power Automate

Azure Logic App - Check multiple conditions

I am trying to check the files count in array and perform below actions
If Count is 0, No action
If Count is 1, perform a specific action
If Count is greater than 1, perform another set of action.
I am using length expression to check the array file count using length(body('Filter_blobs_which_added_in_last_15min'))
Currently I am following below logic ( 2 step condition, first check if the value is zero, and then check if value is 1 or greater than 1). Is there anyway I can combine this into single condition ?
You can achieve this by using Switch condition in your workflow as shown below.
We have created a logic app which will calculate, the number of blobs present in the storage account, using compose & length function (we have calculated the number of blobs) based on the blob count the switch statement associates actions will be executed further.
And also we have tested this in our local environment which is working fine.
Here is the logic app Designer Image:
Here is the code view of the logic app :
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "#length(body('Lists_blobs_(V2)')?['value'])",
"runAfter": {
"Lists_blobs_(V2)": [
"Succeeded"
]
},
"type": "Compose"
},
"Lists_blobs_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/#{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/#{encodeURIComponent(encodeURIComponent('JTJmY29udDE='))}",
"queries": {
"nextPageMarker": "",
"useFlatListing": false
}
},
"metadata": {
"JTJmY29udDE=": "/cont1"
},
"runAfter": {},
"type": "ApiConnection"
},
"Switch": {
"cases": {
"Case": {
"actions": {
"Compose_4": {
"inputs": "length of blob are #{outputs('Compose')}",
"runAfter": {},
"type": "Compose"
}
},
"case": 0
},
"Case_2": {
"actions": {
"Compose_3": {
"inputs": "length of blobs are #{outputs('Compose')}",
"runAfter": {},
"type": "Compose"
}
},
"case": 1
}
},
"default": {
"actions": {
"Compose_2": {
"inputs": "length of blobs are #{outputs('Compose')}",
"runAfter": {},
"type": "Compose"
}
}
},
"expression": "#outputs('Compose')",
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Switch"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Minute",
"interval": 3
},
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/<subId>/resourceGroups/<rgName>/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/<subId>/providers/Microsoft.Web/locations/eastus/managedApis/azureblob"
}
}
}
}
}
Here is the sample output for reference:

Trigger Azure Logic App on the third business day of every month

I'm having problems designing recurrence triggers with logic apps. As far as I know, the logic apps do not support CRON expressions, and running a daily trigger with conditions does not seem to be enough, so I am totally at an loss.
Edit:
To be more precise about my problem, The logic app is for moving files from one server to other and outside constraints dictate that this move should be completed once every month, and the move should happen on the third business day (monday-friday) of the month.
I'm currently pondering on either saving a global variable to tell me whether the app has succesfully ran this month, and using conditions to check every day whether it should run on the day, or starting the running a script which determines if current date is the third weekday of current month, and using that to determine if the logic app should execute or terminate.
You can use recurrence trigger in the logic app to trigger the workflow for every three weeks on Monday .
For more information about recurrence trigger you can refer this documentation.
Updated Answer:
As per the requirement, we have created a logic app with recurrence as a trigger & frequency as day. This workflow will fires every day and will validates whether current date is in between (3,4,5) or not.
if the condition is succeeded it will further executes the logic app actions.
Here is the logic app that we have created:
Here is the code view of the logic app:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose_2": {
"inputs": "#formatDateTime(utcNow(), 'dd')",
"runAfter": {},
"type": "Compose"
},
"Condition": {
"actions": {
"Compose": {
"inputs": "#utcNow()",
"runAfter": {},
"type": "Compose"
}
},
"expression": {
"or": [
{
"equals": [
"#int(outputs('Compose_2'))",
3
]
},
{
"equals": [
"#int(outputs('Compose_2'))",
4
]
},
{
"equals": [
"#int(outputs('Compose_2'))",
5
]
}
]
},
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"type": "If"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Day",
"interval": 1,
"schedule": {
"hours": [
"17"
],
"minutes": [
16
]
},
"startTime": "2021-12-28T17:14:00",
"timeZone": "India Standard Time"
},
"recurrence": {
"frequency": "Day",
"interval": 1,
"startTime": "2021-12-28T17:14:00",
"timeZone": "India Standard Time"
},
"type": "Recurrence"
}
}
},
"parameters": {}
}
Note:
Execution of logic app on every day may result in more billing & also logic app doesn't support any CORN expressions. In these scenarios it is suggested to use Azure time trigger functions instead of logic app.
There are three major options I can see, two of which I would entertain the thought of here. Main reason, due to cost, I've left out the use of the Inline Javascript action because it requires an integration account which will incur substantially more cost than either of the options below.
Prerequisites
The trigger should be a recurrence every day. It will still need to run, it's just whether or not it does anything. There's no getting away from that.
Initialise a variable of type String with the current date. I've included a formula that takes UTC and converts it to your local timezone, you'd just need to change it accordingly.
convertTimeZone(utcNow(), 'UTC', 'AUS Eastern Standard Time')
Option 1 - Azure Function
An Azure Function is by far the easiest way. Create a .NET function app (or whatever language you're comfortable with but you won't be able to use the code below) and from there, create a function with the following code called GetBusinessDayOfMonthForDate ...
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
DateTime dateToProcess = DateTime.Parse(req.Query["Date"]);
int businessDayCount = 0;
var tempDate = dateToProcess;
while (tempDate.Month == dateToProcess.Month)
{
businessDayCount += (tempDate.DayOfWeek.ToString().Substring(0, 1) != "S") ? 1 : 0;
tempDate = tempDate.AddDays(-1);
}
return new OkObjectResult(businessDayCount.ToString());
}
Now call that from Logic Apps directly after the previous action ...
Option 2 - Standard Actions
The basic premise of this approach is the same as the Azure Function but naturally, it's a lot more long winded.
This is the JSON definition for that approach, it includes everything you need to test it in your own environment.
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Condition": {
"actions": {},
"else": {
"actions": {
"Terminate": {
"inputs": {
"runStatus": "Cancelled"
},
"runAfter": {},
"type": "Terminate"
}
}
},
"expression": {
"and": [
{
"equals": [
"#variables('Business Days Up to Today')",
3
]
}
]
},
"runAfter": {
"Until_Day_Index_=_-5": [
"Succeeded"
]
},
"type": "If"
},
"Initialize_Business_Days_Up_to_Today": {
"inputs": {
"variables": [
{
"name": "Business Days Up to Today",
"type": "integer",
"value": 0
}
]
},
"runAfter": {
"Initialize_Temp_Date": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_Current_Date": {
"inputs": {
"variables": [
{
"name": "Current Date",
"type": "string",
"value": "#{convertTimeZone(utcNow(), 'UTC', 'AUS Eastern Standard Time')}"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Initialize_Day_Index": {
"inputs": {
"variables": [
{
"name": "Day Index",
"type": "integer",
"value": 0
}
]
},
"runAfter": {
"Initialize_Business_Days_Up_to_Today": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_Temp_Date": {
"inputs": {
"variables": [
{
"name": "Temp Date",
"type": "string",
"value": "#variables('Current Date')"
}
]
},
"runAfter": {
"Initialize_Current_Date": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Until_Day_Index_=_-5": {
"actions": {
"Decrement_Current_Date": {
"inputs": {
"name": "Temp Date",
"value": "#{addDays(variables('Current Date'), variables('Day Index'))}"
},
"runAfter": {},
"type": "SetVariable"
},
"Decrement_Day_Index": {
"inputs": {
"name": "Day Index",
"value": 1
},
"runAfter": {
"Increment_variable": [
"Succeeded"
]
},
"type": "DecrementVariable"
},
"Increment_variable": {
"inputs": {
"name": "Business Days Up to Today",
"value": "#if(and(greaterOrEquals(dayOfWeek(variables('Temp Date')), 1), lessOrEquals(dayOfWeek(variables('Temp Date')), 6)), 1, 0)"
},
"runAfter": {
"Decrement_Current_Date": [
"Succeeded"
]
},
"type": "IncrementVariable"
}
},
"expression": "#equals(variables('Day Index'), -5)",
"limit": {
"count": 60,
"timeout": "PT1H"
},
"runAfter": {
"Initialize_Day_Index": [
"Succeeded"
]
},
"type": "Until"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Day",
"interval": 1,
"timeZone": "AUS Eastern Standard Time"
},
"recurrence": {
"frequency": "Day",
"interval": 1,
"timeZone": "AUS Eastern Standard Time"
},
"type": "Recurrence"
}
}
},
"parameters": {}
}
At the base all of that, throw in a condition to check if the current business day variable equals 3, if it does, run your logic.
That's included in the JSON definition above.
One of those approach is what I'd be doing so I hope that answers your question.

Resources