azure-data-factoryexpressionbuilder

Data Factory Expression - get a sas token from JSON


I have an output from web activity in Azure Data Factory which generate a JSON containing SAS token for blob storage. I need to pass this SAS Token as an URL to an other Web Activity after every run, as it will expired after 5 minutes.

output example in JSON:

{
    "@odata.context":"https://<baseurl>/data/$metadata#Edm.String",
    "value": "{\"BlobId\":\"{<GUID>}\",\"BlobUrl\":\"https://<baseurl_id>.blob.core.windows.net/dmf/<uniqueFileName>?<SAS Token>\"}"    
}
}

The part that needs to be extracted:

https://<baseurl_id>.blob.core.windows.net/dmf/<uniqueFileName>?<SAS Token>

so far I tried this, by using dynamics content in second web activity:

@activity('web').output.value['BlobUrl']

Could you please support?


Solution

  • Change to

    @json(activity('web').output.value).BlobUrl 
    

    'value' is serialized json, you convert 'value' it to json with the @json function. Then you can access any of the properties easily as .BlobUrl shown above.

    Whenever I am not sure how to extract a certain value from an output I use the SetVariable activity for testing, it can be removed once you have it figured it out.