如何在 Azure Synapse 或数据工厂管道中设置和获取变量值

How to set and get variable value in Azure Synapse or Data Factory pipeline

我已经用 Copy Activity, say, activity1in Azure Synapse Analytics workspace that loads the following JSON to Azure Data Lake Storage Gen2 (ADLSGen2) using source as a REST Api and Sink (destination) as ADLSGen2. Ref 创建了一个管道。

MyJsonFile.json(存储在 ADLSGen2 中)

{"file_url":"https://files.testwebsite.com/Downloads/TimeStampFileName.zip"}

在同一管道中,我需要添加一个 activity2 从上面的 JSON 读取 URL,以及加载 zipactivity3 ] 文件(在那 URL 中提到)到相同的 Gen2 storage.

问题:我们如何在现有管道中添加一个activity2,从上面的JSON中获取URL,然后传递给 activity3?或者,有没有更好的suggestions/solutions来完成这个任务

备注:我已经尝试 Set Variable Activity(如下所示)首先在管道中声明一个变量并使用该变量,例如 myURLVar在此 activity 中,但我不确定如何将 myURLVar 的值动态设置为上述 JSON 中的 URL 的值。请注意 Json 文件名 (MyJsonFile.json) 是一个常量,但 URL 中的 zip 文件名是动态的(基于时间戳),因此我们不能硬编码上面的 url.

正如@Steve Zhao 在评论中提到的,使用 lookup activity 从 JSON 文件中获取数据并提取使用 set variable activity.

从查找输出值中需要 URL
  • lookup activity 连接到先前复制数据的接收器数据集 activity。

查找的输出 activity:

  • 我在集合 activity 中使用 substring 函数从查找输出中提取 URL。

    @replace(substring(replace(replace(replace(string(activity('Lookup1').output.value),'"',''),'}',''),'{',''),indexof(replace(replace(replace(string(activity('Lookup1').output.value),'"',''),'}',''),'{',''),'http'),sub(length(string(replace(replace(replace(string(activity('Lookup1').output.value),'"',''),'}',''),'{',''))),indexof(replace(replace(replace(string(activity('Lookup1').output.value),'"',''),'}',''),'{',''),'http'))),']','')
    

检查设置变量的输出:

设置变量输出值: