如何通过使用Azure数据工厂将文件从Blob加载到sql dw?

时间:2020-02-28 05:32:37

标签: azure-data-factory azure-sqldw

我尝试了很多方法来从中加载数据:

  1. 使用Azure Blob来实现SQL突触的天蓝色。

    我的要求是:
    说明:

     (Input)Blob storage --->  Azure sql synapse(Output)
                    emp_dummy.csv----> emp_dummy table
                    dept_dummy.csv -----> dept_dummy table
                    sales_dummy.csv-----> sales_dummy table   and so on
    

...

我们有以不同名称开头的文件,但格式仅为.csv。 我通过使用getmetadata活动或查找活动以各种方式进行了尝试。

当我尝试以下活动时,遇到错误: [ADF管道] [1] [1]:https://i.stack.imgur.com/RynIb.png 错误:

{
    "errorCode": "2200",
    "message": "ErrorCode=UserErrorMissingPropertyInPayload,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Required property 'fileName' is missing in payload.,Source=Microsoft.DataTransfer.ClientLibrary,'",
    "failureType": "UserError",
    "target": "Copy data1",
    "details": []
}

希望,我提到所有细节,如果需要更多,请告诉我。

2 个答案:

答案 0 :(得分:0)

我知道了。

这是我的示例步骤:将两个csv文件加载到ADW,并使用csv filename自动创建具有相同名称的表。

blob存储中的csv文件:

enter image description here

获取blob容器“ backup”中的所有文件名:

enter image description here

enter image description here

每个项目设置:

@activity('Get Metadata2').output.childItems

enter image description here

在Foreach中有效复制:

在活动副本中,使用另一个Blob源,添加参数以选择文件: enter image description here enter image description here

来源设置:

enter image description here

接收器数据集(ADW): enter image description here enter image description here

接收器设置:

enter image description here

表名表达式:@split(item().name, '.')[0]

注意::获取元数据将获得完整文件名,例如“ test.csv”,当我们设置表名时,我们需要将其拆分并将表名设置为“ test”。

执行管道: enter image description here

在ADW中检查数据enter image description here

希望这会有所帮助。

答案 1 :(得分:0)

我为您做了Google搜索。我在那里找到了几本非常糟糕的教程。下面的两个链接看起来很不错。

https://intellipaat.com/blog/azure-data-factory-tutorial/

https://medium.com/@adilsonbna/using-azure-data-lake-to-copy-data-from-csv-file-to-a-sql-database-712c243db658

请记住,当您使用Azure Data Factory从文件存储中复制数据时,现在可以配置通配符文件筛选器,以使“复制活动”仅拾取具有定义命名模式的文件,例如“ * .csv”或“ ??? 20180504.json”。

作为参考,请看下面的图片。

enter image description here

如果要遍历Blob环境中不同文件夹中的所有文件,而不是将文件或文件夹设置为此:

adfv2/SalesJan2009.csv

您可以将文件或文件夹设置为此:

adfv2/Sales*2009.csv

这会将2009年以来的所有Sales数据合并到一个数据框中,您可以将它们加载到SQL Server(数据仓库,Synapse等)中。