我已使用向导创建了一个 ADF,该向导将数据从 Azure SQL 复制到 Blob 存储。
在指定输出文件名的选项(参见屏幕截图)中,我想附加到文件名、文件创建日期或其他一些变量值。有办法做到这一点吗?
最佳答案
除了使用 the Data Factory Copy Wizard您还可以通过编辑控制文件创建的 OutputDataset 的 json 配置来更改 blob 文件的文件路径和/或文件名(在设置复制管道之后),如下所示:
- 转到 OutputDataset 表源(json 配置)。为此,您可以,例如,
- 打开数据工厂的“数据工厂”边栏选项卡。
- 在“内容”下,单击“数据集”以打开“数据集”边栏选项卡。
- 单击要调整其命名的 OutputDataset。这将打开 OutputDataset 边栏选项卡。
- 单击“表源”图 block 。您将定向到 OutputDataset 的 json 配置设置。
- 在partitionedBy属性下添加或调整变量,如下所示 下面的例子。 (参见“firstCustomVariable”。)
- 根据您的需求调整文件名和/或文件路径以使用变量,如下例所示。 (参见例如“blobFileName-{firstCustomVariable}.json.gz”。)
另请参阅:
V1:Azure Data Factory - Functions and System Variables
V2:System variables supported by Azure Data Factory
V2:How to read or write partitioned data in Azure Data Factory version 2
Custom Date and Time Format Strings
示例:
{
"name": "OutputDataset-abc",
"properties": {
"published": false,
"type": "AzureBlob",
"linkedServiceName": "Destination-BlobStorage-abc",
"typeProperties": {
"fileName": "blobFileName-{firstCustomVariable}.json.gz",
"folderPath": "folderName-{secondCustomVariable}",
"format": {
"type": "JsonFormat",
"filePattern": "arrayOfObjects"
},
"partitionedBy": [
{
"name": "firstCustomVariable",
"value": {
"type": "DateTime",
"date": "SliceStart",
"format": "yyyyMMddHH"
}
},
{
"name": "secondCustomVariable",
"value": {
"type": "DateTime",
"date": "SliceStart",
"format": "MM"
}
}
],
"compression": {
"type": "GZip",
"level": "Fastest"
}
},
"availability": {
"frequency": "Day",
"interval": 1
},
"external": false,
"policy": {}
}
}
关于azure - 如何对写入 Blob 存储的 Azure 数据工厂文件进行可变命名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40341078/