2

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!

Casper Jensen
  • 551
  • 1
  • 5
  • 15

2 Answers2

4

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.

petezurich
  • 9,280
  • 9
  • 43
  • 57
3

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.

Kyle Bunting
  • 176
  • 4
  • It's a pity that you can't check for the HTTP status code result - you have to return the code in the body json – Rodney Nov 25 '18 at 10:54
  • ADF does some checking for the code, and will report success on the Web Activity if the code is between 200 and 299. If you send back a failure code, 404 or 500 for example, it will result in the web activity failing. If you want to actually use the code, then yes, you will need to return it in your JSON response. – Kyle Bunting Nov 26 '18 at 12:30
  • Yes, I would like to handle 500 exceptions, but it seems to shutdown processing in ADF when my logic app throws these – Rodney Dec 11 '18 at 06:17