question

Peter-7064 avatar image
0 Votes"
Peter-7064 asked TerriblyVexed-7343 commented

BUG in Azure Data Factory -> Set Variable -> Add dynamic content -> content contains a dash in its name

Hi,

I am attempting to set a variable by referring to an element inside a json array.

The array element has dashes (-) in its name.

This fails:
@array([activity('Get Item Count').output.ADFWebActivityResponseHeaders.X-Total-Count])

This succeeds:
@array([activity('Get Item Count').output.ADFWebActivityResponseHeaders.ServerName])

Does anybody know how to escape the dashes?

I have tried all sorts of combinations using \ / , ' " to no avail.

The error I get is:

{
"code":"BadRequest",
"message":"ErrorCode=InvalidTemplate,
ErrorMessage=Unable to parse expression 'array([activity('Get Item Count').output.ADFWebActivityResponseHeaders.X-Total-Count])'",
"target":"XXXXX",
"details":null,
"error":null
}

azure-data-factory
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Peter-7064,

Welcome to Microsoft Q&A Platform. Thanks for posting the query.

Yes, I am able to reproduce the issue. I will reach out to product team to understand the possible ways to handle such names and will share with you once I hear back from them.

Stay tuned!

1 Vote 1 ·

Hi @Peter-7064,

I got confirmation from product team that this is a known limitation and they suggested on renaming the element without '-' in it. I am working with the team to understand if there is any possibility to rename the element in the pipeline if its not feasible to modify the output from web activity. I will let you know once I hear back from them.

0 Votes 0 ·

Hi @HarithaMaddi-MSFT,

Renaming is not possible as the element is a header that is returned from a third party REST API. I am then trying to reference that particular element (with the '-') by name in an attempt to get its value.

Cheers.

0 Votes 0 ·
Show more comments
dphugo avatar image
2 Votes"
dphugo answered HarithaMaddi-MSFT commented

Hi @Peter-7064

I also hit this issue today.
Have you tried this solution?
https://stackoverflow.com/questions/61937105/data-factory-retrieve-value-from-field-with-dash-from-json-file

So in your case it would be:
@array([activity('Get Item Count').output.ADFWebActivityResponseHeaders['X-Total-Count']])

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @dphugo

Thank you very much for the message and link. That was exactly what I needed to do.

Solved.

1 Vote 1 ·

Thanks @dphugo for providing the resolution. I got same update from Product team today and I was about to inform @Peter-7064 the same.

Appreciate the help!

1 Vote 1 ·
TerriblyVexed-7343 avatar image
0 Votes"
TerriblyVexed-7343 answered TerriblyVexed-7343 commented

I ran into this today also. It is happening in a ForEach activity. I'm trying to get the Content-Location returned from a Web Activity Response Header.
Output
{
"Response": "",
"ADFWebActivityResponseHeaders": {
"Request-Context": "appId=cid-v1:.....",
"X-Request-ID": "66832d597403aa4e8c521f1bc837fadb",
"x-ms-session-token": "0:-1#638764",
"x-ms-request-charge": "19.85",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"Date": "Mon, 25 Oct 2021 14:22:29 GMT",
"Server": "Kestrel",
"Content-Length": "0",
"Content-Location": " https://site.azurehealthcareapis.com/_operations/export/416cddbd-071e-48e5-9952-00774d30e5bd "
},
"effectiveIntegrationRuntime": "IntegrationRuntime (North Central US)",
"executionDuration": 0,

The provided workaround is NOT working for me. In my ForEach Items I have:
@array([activity('StartExportTask').output.ADFWebActivityResponseHeaders.['Content-Location']])

and I get:
Error
Notifications
{"code":"BadRequest","message":null,"target":"pipeline//runid/1f5588ce-b4bf-4841-bf66-865594371c97","details":null,"error":null}

also I try:

@activity('StartExportTask').output.ADFWebActivityResponseHeaders.['Content-Location']

With the same results. Please help.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @TerriblyVexed-7343,

It seems you have an extra period in your function. When you index into the node-object it's just square brackets.
So instead of
ADFWebActivityResponseHeaders.['Content-Location']

it's just
ADFWebActivityResponseHeaders['Content-Location']

So depending on your use case the full line would be, either:

 @array([activity('StartExportTask').output.ADFWebActivityResponseHeaders['Content-Location']])

or

 @activity('StartExportTask').output.ADFWebActivityResponseHeaders['Content-Location']





1 Vote 1 ·

Doh! Yep that was it. Rooky mistake.
Thanks

1 Vote 1 ·