Harry Leboeuf
Harry Leboeuf

Reputation: 745

ADF V2 Error the string character '@' at position is not expected

This is a double post with MSDN, but didn't get any help there so i'm hoping some expert sees it here.

I started from the example found at https://learn.microsoft.com/en-us/azure/data-factory/tutorial-incremental-copy-powershell

"name": "SinkDataset",
    "properties": {
        "type": "AzureBlob",
        "typeProperties": {
            "folderPath": "adftutorial/incrementalcopy",
            "fileName": "@CONCAT('Incremental-', pipeline().RunId, '.txt')", 
            "format": {
                "type": "TextFormat"
            }
        },

My code became

"typeProperties": {
            "fileName": "S1073_PBI_DAY_JUSTIF_VW.csv",
            "folderPath": "@CONCAT('bict2233/data-in/day/', @{dataset().TriggerRunTime})",
            "format": {
                "type": "TextFormat",
....

But i'm getting this error

Invoke-AzureRmDataFactoryV2Pipeline : HTTP Status Code: BadRequest
Error Code: BadRequest
Error Message: The template validation failed: 'the string character '@' at position '32' is not expected..'.
Request Id: 55664c55-8a20-403b-9fbf-a4c24166b473
Timestamp (Utc):12/14/2017 15:37:59
At C:\ADF\bict2233_A\Powershell\T.ps1:25 char:10
+ $runId = Invoke-AzureRmDataFactoryV2Pipeline -PipelineName "lstgDayJu ...
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Invoke-AzureRmDataFactoryV2Pipeline], ErrorResponseExceptio

Any idea why ?

Thx

Upvotes: 4

Views: 5890

Answers (2)

Harry Leboeuf
Harry Leboeuf

Reputation: 745

I did find the problem.

"folderPath": "@concat('bict2233/data-in/day/', formatDateTime(dataset().TriggerRunTime,'yyyyMMddHH'))"

Should be used like

"folderPath": {
"value": "@concat('bict2233/data-in/day/', formatDateTime(dataset().TriggerRunTime,'yyyyMMddHH'))",
"type": "Expression"
}

Upvotes: 3

Martin Esteban Zurita
Martin Esteban Zurita

Reputation: 3209

I'm by no means an expert, but I think I can help you a bit.

Looking at the documentation https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#string-functions I found that the concat function only applies to strings, and you are trying to concatenate a string 'bict2233/data-in/day/' with a datetime value in @{dataset().TriggerRunTime}.

Maybe you could try converting the value to a string just to be safe. You can do that using a conversion function, it would look something like this:

            "folderPath": "@CONCAT('bict2233/data-in/day/', @string(@{dataset().TriggerRunTime}))"

I hope this helps you! :)

Upvotes: 1

Related Questions