将Web Activity调用的输出用作变量 [英] Use output from Web Activity call as variable

查看:97
本文介绍了将Web Activity调用的输出用作变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ADFv2传输一些数据.作为此操作的一部分,我需要一些配置值才能传递到管道中.

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

必须在运行时从REST服务中提取配置值-不能作为参数.

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

我可以使用Web Activity成功查询REST服务,并且可以在调试视图中看到输出.

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

现在是问题:)

如何在管道的其他活动中使用此输出?

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

我的Web活动配置如下:

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!

推荐答案

在ADFv2中,您可以使用@activity('ActivityName').output访问先前活动的输出.

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

对于定义的Web活动,函数的响应应为JSON格式,因此您将在响应中使用其属性名称来引用特定的JSON值.例如,您定义的名为Web1的Web活动将调用一个函数,该函数返回以下响应:

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"
}

要在后续的ADF活动中使用foo的值,请引用@activity('Web1').output.foo.如果需要将返回值转换为另一种类型,则ADFv2提供了多种类型转换功能.

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.

如果您的函数返回了一个空的JSON响应,则您可能希望使用Postman或其他工具检查函数的响应,以确保您返回的是格式正确的响应,并且您的函数不会因为其他原因而失败

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.

在Azure函数代码中,您应该返回一个JSON对象以及与return req.CreateResponse(HttpStatusCode.OK, json);类似的成功代码.

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);.

还请注意,如果您引用响应的属性并且该属性不存在,则ADF将在该点失败,因此您可以使用If Condition活动来检查所需的值,以更好地处理ADFv2中的失败.

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.

这篇关于将Web Activity调用的输出用作变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆