user4093045
user4093045

Reputation:

Azure Data Factory: StartDate in Default Parameters

I'm trying to specify a default value for startDate parameter as shown below:

enter image description here

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() ?

Upvotes: 2

Views: 4510

Answers (3)

user4093045
user4093045

Reputation:

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.

Upvotes: 0

DraganB
DraganB

Reputation: 1138

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.

Upvotes: 1

DraganB
DraganB

Reputation: 1138

You can use utcnow() function, or if you will define trigger you can use trigger().startTime. Other Date functions you can find here.

Upvotes: 2

Related Questions