Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use output from Web Activity call as variable

I'm using ADFv2 to transfer some data. As a part of this operation I need some configuration values to pass into the pipeline.

The config values must be pulled at runtime from a REST service - not as parameters.

I can successfully query the REST service with Web Activity and I can see the output in the debug view.

Now the problem :)

How do I use this output in other activities further in the pipeline?

My Web Activity configuration is like this:

{
"name": "Web1",
"type": "WebActivity",
"policy": {
   "timeout": "7.00:00:00",
   "retry": 0,
   "retryIntervalInSeconds": 30,
   "secureOutput": false
},
"typeProperties": {
   "url": "https://myazurefunction.azurewebsites.net/api/MyFunction",
   "method": "GET",
   "headers": {
   "Content-Type": "application/json"
   }
}

I have tried to access the output after is has executed, but it seems empty:

@activity('Web1').Output
@activity('Web1').output
@string(activity('Web1').Output)

they are all empty. Any suggestions? Thanks!

like image 365
Casper Jensen Avatar asked Apr 02 '26 09:04

Casper Jensen


2 Answers

I set up an ADF2 and try to get a response.

This works for me:

@string(activity('Post').output)

Have you checked the output in the debugging?

Here is my output:

{
    "test": {
        "value": 123,
        "text": abc
    },
    "concat": 123abc
}

I use the stored procedure to insert the values into the destination table on a Logical Server.

like image 158
Benjamin Laerbusch Avatar answered Apr 04 '26 12:04

Benjamin Laerbusch


In ADFv2, you access the output of previous activities using @activity('ActivityName').output.

For the web activity defined, the response from your function should be in JSON format, so you would reference specific JSON values using their attribute names in the response. For example, your defined web activity, named Web1, calls a function that returns a response of:

{
  "foo": "bar",
  "some": "value"
}

To use the value of foo in a subsequent ADF activity, you would reference @activity('Web1').output.foo. ADFv2 provides multiple type conversion functions, should you need the returned value converted to another type.

If your function is returning an empty JSON response back, you may want to inspect the response from your function using Postman or another tool to ensure you are returning a properly formatted response, and that your function isn't failing for another reason.

Inside your Azure function code, you should be returning a JSON object, along with a success code, similar to return req.CreateResponse(HttpStatusCode.OK, json);.

Also note that if you reference a property of the response and it does not exist, ADF will fail at that point, so you can use an If Condition activity to check for the required values to better handle failures in ADFv2.

like image 44
Kyle Bunting Avatar answered Apr 04 '26 14:04

Kyle Bunting



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!