【问题标题】:Use Azure Data Factory (without MapReduce) to import and unzip archives to a Blob Storage使用 Azure 数据工厂(不带 MapReduce)将存档导入和解压缩到 Blob 存储
【发布时间】:2017-08-20 06:52:52
【问题描述】:

我必须将各种 zip 文件从 ftp 服务器导入到一些 Azure SQL 表。每个 zip 文件最多包含 10 个不同结构的文本 (csv) 文件,即第一个文本文件中的行格式为

“1|星期一|2017-03-20|345671”

而第二个文本文件中的行的格式为,例如,

“abc|345894|xyz||2|yyy|true|3”。

我不想使用 MapReduce(或自定义活动),因为它既昂贵又缓慢(Microsoft Azure 支持建议先使用 HDInsight(按需)MapReduce 活动来解压缩文件)。

【问题讨论】:

    标签: ftp zip compression azure-data-factory azure-blob-storage


    【解决方案1】:

    定义必要的链接服务,对我来说是一个 FTP 链接服务,然后使用 FileShare 类型的数据集从源(FTP 服务器)获取文件。在此数据集中,断言文件已压缩:

    {
        "name": "myFTPFileInput",
        "properties": {
        "published": false,
        "type": "FileShare",
        "linkedServiceName": "myFTPLinkedService",
        "typeProperties": {
            "fileName": "xyz20170316.zip",
            "useBinaryTransfer": "true",
            "folderPath": "/Products/xyzProducts",
            "compression": {
                "type": "ZipDeflate",
                "level": "Optimal"
            }
        },
        "availability": {
            "frequency": "Day",
            "interval": 15
        },
        "external": true,
        "policy": {}
        }
    }
    

    使用 Blobsink 将文件写入 Blob 存储:

    {
        "name": "myAzureBlobOutput",
        "properties": {
        "published": false,
        "type": "AzureBlob",
        "linkedServiceName": "myAzureStorageLinkedService",
        "typeProperties": {
            "folderPath": "mytest/ftp/xyz/{Year}/{Month}",
            "format": {
                "type": "TextFormat",
                "rowDelimiter": "\n",
                "columnDelimiter": "|"
            },
            "partitionedBy": [
                {
                    "name": "Year",
                    "value": {
                        "type": "DateTime",
                        "date": "SliceStart",
                        "format": "yyyy"
                    }
                },
                {
                    "name": "Month",
                    "value": {
                        "type": "DateTime",
                        "date": "SliceStart",
                        "format": "MM"
                    }
                }
            ]
        },
        "availability": {
            "frequency": "Day",
            "interval": 15
        }
      }
    }
    

    数据将被解压缩并作为文本写入指定的文件夹。从那里我可以使用标准 ADF 复制活动将每个文件导入到相应的 Azure SQL 表中。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-08
      • 2020-12-22
      • 2016-08-30
      • 2021-04-14
      • 2019-04-20
      • 2021-01-16
      • 2019-01-26
      • 2017-04-05
      相关资源
      最近更新 更多