简体   繁体   English

Azure数据工厂V2动态内容

[英]Azure Data Factory V2 Dynamic Content

Long story short, I have a data dump that is too large for an azure function.长话短说,我的数据转储对于 azure function 来说太大了。 So we are using Data Factory.所以我们正在使用数据工厂。 I have tasked another function to generate an access token for an API and output it as part of a json.我已委托另一个 function 为 API 和 output 生成访问令牌,将其作为 Z464Z855DE76ECDDF24DZ 的一部分I would like to set that token to a variable within the pipeline.我想将该令牌设置为管道中的一个变量。 So far I have this:到目前为止,我有这个: 在此处输入图像描述

I'm attempting to use the Dynamic Content "language" to set the variable:我正在尝试使用动态内容“语言”来设置变量:

@activity('Get_Token').output

I'd like something like pythons:我想要蟒蛇之类的东西:

token = data.get('data', {}).get('access_token', '')

As a secondary question, my next step is to use this token to call an API while iterating over another output, so perhaps this exact step can be added into the ForEach?作为第二个问题,我的下一步是在迭代另一个 output 时使用这个令牌调用 API,所以也许这个确切的步骤可以添加到 ForEach 中?

Looks like the variable should be @activity('Get token').output.data.access_token as others have indicated but, as you've guessed, there's no need to assign a variable if you only need it within the foreach.看起来变量应该是@activity('Get token').output.data.access_token正如其他人所指出的那样,但正如您所猜测的,如果您只需要在 foreach 中分配变量,则无需分配变量。 You can access any predecessor output from that successor activity.您可以从该后继活动访问任何前任 output。 Here's how to use the token while iterating over another output:以下是在迭代另一个 output 时如何使用令牌:

  1. Let's say your function also outputs listOfThings as an array within the data key.假设您的 function 还将listOfThings作为data键中的数组输出。 Then you can set the foreach activity to iterate over @activity('Get token').output.data.listOfThings .然后,您可以将 foreach 活动设置为迭代@activity('Get token').output.data.listOfThings
  2. Inside the foreach you will have (let's say) a Copy activity with a REST dataset as the source.在 foreach 中,您将拥有(比方说)一个以 REST 数据集作为源的复制活动。 Configure the REST linked service with anonymous auth...使用匿名身份验证配置 REST链接服务...
  3. ... then you'll find a field called Additional Headers in the REST dataset where you can create a key Authorization with value as above, Basic @activity('Get token').output.data.access_token ...然后您会在 REST数据集中找到一个名为Additional Headers的字段,您可以在其中创建具有上述值的密钥AuthorizationBasic @activity('Get token').output.data.access_token
  4. The thing that you said you want to iterate over (in the listOfThings JSON array) can be referenced inside the foreach activity with @item() (or, if it's a member of an item in the listOfThings iterable then it would be @item().myMember )您说要迭代的东西(在listOfThings JSON 数组中)可以在 foreach 活动中使用@item()引用(或者,如果它是 listOfThings 可迭代项中某个项目的成员,那么它将是@item().myMember )

To make #4 explicit for anyone else arriving here:为了让其他到达这里的人明确#4:

  • If listOfThings looks like this, listOfThings: [ "thing1", "thing2", ...]如果 listOfThings 看起来像这样, listOfThings: [ "thing1", "thing2", ...]

  • for example, filenames: ["file1.txt", "file2.txt", ...]例如, filenames: ["file1.txt", "file2.txt", ...]

  • then @item() becomes file1.txt etc.然后@item()变成file1.txt等等。

whereas然而

  • If listOfThings looks like this, listOfThings: [ {"key1":"value1", "key2":"value2"... }, {"key1":"value1", "key2":"value2"... }, ...]如果 listOfThings 看起来像这样, listOfThings: [ {"key1":"value1", "key2":"value2"... }, {"key1":"value1", "key2":"value2"... }, ...]

  • for example.例如。 filenames: [ {"folder":"folder1", "filename":"file1.txt"}, {"folder":"folder2", "filename":"file2.txt"}, ... ]

  • then @item().filename becomes file1.txt etc.然后@item().filename变成file1.txt等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM