简体   繁体   English

用于创建新文件夹的 Azure 数据工厂 utcNow() 动态函数

[英]Azure Data Factory utcNow() dynamic function used to create new folder

I'm using Copy Data activity to send data to Azure Data Lake Storage Gen2.我正在使用复制数据活动将数据发送到 Azure Data Lake Storage Gen2。 To do so, I must create a new folder every day that has the current timestamp at the end of it.为此,我必须每天创建一个新文件夹,该文件夹的末尾带有当前时间戳。 So today my pipeline launches, in the proper path in the Storage Explorer I should see:所以今天我的管道启动,在存储资源管理器的正确路径中,我应该看到:

Folder_name_2021-11-02 Folder_name_2021-11-02

I don't care about the format, I just need the date.我不在乎格式,我只需要日期。 In 'path' ('Sink' section of Copy data activity) I wrote:在“路径”(复制数据活动的“接收器”部分)中,我写道:

@parent_folder/folder_name_utcNow() @parent_folder/folder_name_utcNow()

But I get the following error: @parent_folder/folder_name_utcNow() is not valid: the string character '/' at position '13' is not expected.但我收到以下错误:@parent_folder/folder_name_utcNow() 无效:位置 '13' 处的字符串字符 '/' 不是预期的。

You need to create the string in the right format and put it in the right place.您需要以正确的格式创建字符串并将其放在正确的位置。 Here is an example where I am using concat to join multiple strings with formatDateTime to convert the output of utcNow into a format I can use in a filename.这是一个示例,我使用concat将多个字符串与formatDateTime连接起来,以将utcNow的输出转换为我可以在文件名中使用的格式。 I am using this dynamic content in the filepath property of the Sink output dataset.我在 Sink 输出数据集的 filepath 属性中使用此动态内容。

NB I am using the forward slashes in my format string ensure I get that data lake hierarchy.注意我在格式字符串中使用正斜杠确保我获得了数据湖层次结构。 If you just want a single file with the date in it, replace them with underscores or remove them altogether:如果您只想要一个带有日期的文件,请用下划线替换它们或将它们完全删除:

@concat('raw/ball/', formatDateTime(utcNow(), 'yyyy/MM/dd/HH/mm/'))

The output dataset:输出数据集:

在此处输入图片说明

You probably want something like:你可能想要这样的东西:

@concat('raw/parent_folder/folder_name_/', formatDateTime(utcNow(), 'yyyyMMdd'))

Although it is more common to use the date folders as per my original example.尽管按照我的原始示例使用日期文件夹更为常见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM