在 ADF V2 中 - 如何将日期 ("yyyyMMdd")) 动态附加到 S3 数据集的文件名

In ADF V2 - how to append date ("yyyyMMdd")) to filename dynamically for S3 dataset

我目前正在努力在源数据位于 S3 中的 ADFv2 中实现管道自动化。每天创建一个新文件,其结构为 "data_20180829.csv"

我已尝试检测动态内容以在复制数据 Activity 的文件名字段中完成此操作。然而,即使我尝试像 @{concat('data_','20180829.csv')} 这样简单的事情(应该解析为正确的值),源也会失败。

有什么方法可以查看动态内容将解析为什么?

这应该只是在数据集中设置文件名表达式的问题,例如

请注意,设置是在数据集上完成的,而不是在复制 activity 级别。另请注意,您可以通过将 utcnow 函数与 formatDateTime 结合使用来使表达式更加动态,例如:

@concat('data_',formatDateTime(utcnow(),'yyyMMdd_HHmmss'),'.csv')

仔细注意格式化字符串的大小写。大写 MM 是两位数格式的月份。 HH 是 24 小时格式的小时。格式化字符串的完整列表是 here.

数据集的 json 如下所示:

{
    "name": "DelimitedText3",
    "properties": {
        "linkedServiceName": {
            "referenceName": "linkedService2",
            "type": "LinkedServiceReference"
        },
        "annotations": [],
        "type": "DelimitedText",
        "typeProperties": {
            "location": {
                "type": "AzureBlobStorageLocation",
                "fileName": {
                    "value": "@concat('data_',formatDateTime(utcnow(),'yyyMMdd_HHmmss'),'.csv')",
                    "type": "Expression"
                },
                "container": "ang"
            },
            "columnDelimiter": ",",
            "escapeChar": "\",
            "quoteChar": "\""
        },
        "schema": [
            {
                "type": "String"
            },
            {
                "type": "String"
            },
            {
                "type": "String"
            },
            {
                "type": "String"
            }
        ]
    }
}

只是为了扩展 wBob 所说的内容。如果你想要像 foo_YYYY\MM\DD\ 这样的结构,你总是可以使用这个

@concat('foo-name','/',formatDateTime(utcnow(),'yyyy'),'/',formatDateTime(utcnow(),'MM'),'/',formatDateTime(utcnow(),'dd'))