Logic Apps: What is the "evaluatedRecurrence" trigger property? - azure

Title says it all. The evaluatedRecurrence property of Logic App triggers is undocumented and not settable through the logic app designer. It seems redundant.
I can find no answer to this question and not even a similar question. The only thing I can find is in the Readme of this repo, where the option "IncludeEvaluatedRecurrence" says "this is a non documented object".
So, my question(s) is/are:
What is this property?
How does it compare to the "normal" recurrence property?
Does every evaluation count as an action?
Example code:
"triggers": {
"Every_x_minutes": {
"recurrence": {
"frequency": "Minute",
"interval": "#parameters('RunFrequencyMinutes')",
"timeZone": "W. Europe Standard Time"
},
"evaluatedRecurrence": {
"frequency": "Minute",
"interval": 3,
"timeZone": "W. Europe Standard Time"
},
"type": "Recurrence"
}
}

What is this property?
The EvaluatedRecurrence property is when the recurrence trigger is being referenced by any expression or parameter. In general, it remains the same as recurrence unless it doesn't have any references.
How does it compare to the "normal" recurrence property?
When the trigger is referenced by any expression or parameter it will be evaluated under "evaluatedRecurrence". The "normal" recurrence property is something that will be triggered at times as we scheduled.
Does every evaluation count as an action?
Not necessarily, unless it is referenced by some parameter.
You can also follow Can't find the meaning/definition and example of trigger property called "evaluatedRecurrence" for further information.

Related

Run Azure Logic app only first 5 days per month

as i mentioned in the topic i need to run a trigger only first 5 days of each month. Any ideas how to do it?
I tried to check with Recurrence trigger but did not find how to do it.
Thanks in advance.
Looking at the Recurrence documentation, it looks like you can specify a monthly recurrence with monthDays using the JSON definition.
Worth trying something like :
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Month",
"interval": 1,
"schedule": {
"monthDays": [1, 2, 3, 4, 5]
}
},
"type": "Recurrence"
}
}
While setting this up, keep in mind the following though :

Azure Data Factory V2 using yesterdays date when triggering a pipeline run

I have an Azure Data Factory (v2) that I use to backup the contents of a database to a blob store nightly (2am UTC). However, I expect the name of the file to contain the day of the month (dd) that the backup was generated, but it's always the day before.
The file name is generated using an expression -
#{formatDateTime(pipeline().parameters.windowStart,'dd')}.json
So for example the run at 3am today should have been called 23.json, but it was actually called 22.json. 3am is the expected run time as I'm in the UK, which is currently on BST (UTC+1)
Looking at the parameters of the run, I can see that the windowStart is indeed a day out. For example, todays run which was triggered at 2am on the 23rd had 9/22/2020 2:00:00 AM.
Is anybody able to explain why Data Factory is behaving in this way, and hopefully how I can make it work as expected.
Here is the trigger as exported from the Data Factory.
{
"name": "Trigger_Copy_Transactions",
"properties": {
"annotations": [],
"runtimeState": "Started",
"pipeline": {
"pipelineReference": {
"referenceName": "Copy_Transactions",
"type": "PipelineReference"
},
"parameters": {
"windowStart": "#trigger().outputs.windowStartTime"
}
},
"type": "TumblingWindowTrigger",
"typeProperties": {
"frequency": "Hour",
"interval": 24,
"startTime": "2020-08-24T02:00:00Z",
"delay": "00:00:00",
"maxConcurrency": 50,
"retryPolicy": {
"intervalInSeconds": 30
},
"dependsOn": []
}
}
}
One thing you could try is to force the file to be generated in the same time zone that your IR is running in. For example we have a Self Hosted IR so when we would generate files it would not match EST times. In that case I did the following:
#concat('File_name',formatDateTime(
convertFromUtc(utcnow(),'Eastern Standard Time'),'yyyy-MM-dd'),'.txt')
Perhaps doing that would force the proper date?
Are you also using Auto-generated IR or Self-Hosted IR when running this job?

Azure data factory pipeline: conditional checking on variable activity

I have a web activity to call a REST API and save it output into a table. But one of its value will not available always. So we need to do a conditional checking while setting its output into a variable activity.
you can see how we have done that in the variable activity.
This is the rest APIs output.
{
"value": {
"id": "464a115fd3cb",
"runId": "464a115fd3cb",
"parameters": {},
"invokedBy": {
"id": "99448303872CU28",
"name": "TRIGGER_TIMESHEET_API",
"invokedByType": "ScheduleTrigger"
},
"isLatest": true
},
"continuationToken": "+RID:~sj5QALRCCB4w5hYAAAAADQ",
"ADFWebActivityResponseHeaders": {
"Pragma": "no-cache"
}
}
Here "continuationToken" will not be a part of all the API responses. So if this value is available in the API response, we need to set that in the variable activity.
In the attached screenshot, you can see that we are setting the variable. But if that key is not available in the API response, it will throw an error.
So we are looking for a solution to check whether that key is existing in the JSON output.
Any help appreciated.
I think you almost get your goal already,please use Set Variable Activity and If-Condition Activity:
Set Variable Activity:
If-Condition Activity to judge the name is empty or not:
Then you could configure the True Activity and False Activity:

Azure Data Factory: StartDate in Default Parameters

I'm trying to specify a default value for startDate parameter as shown below:
I've been checking how to specify so with functions but so far have I have not find anything.
So far I'm specifying a manual value for startDate, but the idea is to get the current date every time the schedule runs.
I have this defined in a blob storage destination (where it is being used):
#{formatDateTime(pipeline().parameters.windowStart,'yyyy')}#{formatDateTime(pipeline().parameters.windowStart,'MM')}#{formatDateTime(pipeline().parameters.windowStart,'dd')}#{formatDateTime(pipeline().parameters.windowStart,'HH')}#{formatDateTime(pipeline().parameters.windowStart,'mm'
Is there a way to replace the fact of calling the parameter and use directly utcnow() ?
You can use utcnow() function,
or if you will define trigger you can use trigger().startTime.
Other Date functions you can find here.
formatDateTime function you use where you want to return a string in specific date format.
if the format is not imported for you, and you just want the current date, then you can use trigger().startTime or utcnow() in expression field. Don't forget # sign.
trigger().startTime.utcnow is not valid expression.
Finally I was able to fix this by creating the trigger using a JSON code as shown below:
{
"name": "yourTriggerName",
"properties": {
"runtimeState": "Started",
"pipelines": [
{
"pipelineReference": {
"referenceName": "YourPipelineName",
"type": "PipelineReference"
},
"parameters": {
"windowStart": "#trigger().scheduledTime"
}
}
],
"type": "ScheduleTrigger",
"typeProperties": {
"recurrence": {
"frequency": "Day",
"interval": 1,
"startTime": "2018-07-11T17:00:00Z",
"timeZone": "UTC",
"schedule": {
"minutes": [
20
],
"hours": [
19
]
}
}
}
}
}
And making emphasis of course, in line below:
"parameters": {
"windowStart": "#trigger().scheduledTime"
After that, the copy activity started to work as expected.

Logic App - HTTP Action - Loop until 200

I have a logic app with an http action.
As the reply policy allows at most 4 retries I put the activity inside a do-until loop (with max count and timeout) using the http status code as escape variable (until it is 200).
This image should make this more clear
At runtime I get this error
[EDIT]InvalidTemplate. Unable to process template language expressions for action 'HTTPAction'[EDIT]: Unable to process template language expressions for action 'HttpAction' [..] The template language expression 'equals(outputs('HttpAction')['statusCode'], 200)' cannot be evaluated because property 'statusCode' cannot be selected.
Any hints?
Thanks, Alessandro
[EDIT]The http request just works (tried with fiddler), in the workflow i suppose it just doesn't get executed due to the template error (why does it fail at runtime and not in edit mode?)[EDIT]
Going to reply for readable code.
I just made a quick POC to simulate your scenario, but I can't reproduce your issue.
Code of my Do-Until:
"Until": {
"actions": {
"HttpGetMyValues": {
"inputs": {
"headers": {
"Ocp-Apim-Subscription-Key": "#parameters('OcpApimSubscriptionKey')"
},
"method": "GET",
"uri": "https://myendpointuri"
},
"runAfter": {},
"type": "Http"
}
},
"expression": "#equals(outputs('HttpGetMyValues')['statusCode'], 200)",
"limit": {
"count": 1,
"timeout": "PT1M"
},
"runAfter": {},
"type": "Until"
}
I can save and run the Logic App without problems.
Retry policy is configurable, currently only available via code view, but we plan to enable it in designer very soon. Here's the documentation.
"retryPolicy" : {
"type": "<type-of-retry-policy>",
"interval": <retry-interval>,
"count": <number-of-retry-attempts>
}
I know this is late to the game, but the error is due to the condition that ends the 'do-until' loop being contained within the loop itself. You'll need to use a value that is outside of the loop as reference. I suggest:
Creating a variable before the 'do-until' action with the default value as '400'
Using the variable as the value the 'Status code' value needs to equal
Updating (set-variable in Logic Apps) the variable at the end of each loop iteration to equal the 'Status code'.
In the Until control:
Click Edit Advanced Mode
Replace the text with #equals(actions('HTTPAction').status, 'Succeeded')
The code means stop do until loop when the HTTPAction has completed

Resources