使用 utcnow() 作为管道参数的 Azure 数据工厂 v2

标签 azure azure-data-factory

就上下文而言,我目前有一个数据工厂 v2 管道,其中包含一个调用复制事件ForEach Activity复制事件只是将数据从 FTP 服务器复制到 Blob 存储容器。

这是管道 json 文件:

{
    "name": "pipeline1",
    "properties": {
        "activities": [
            {
                "name": "ForEach1",
                "type": "ForEach",
                "typeProperties": {
                    "items": {
                        "value": "@pipeline().parameters.InputParams",
                        "type": "Expression"
                    },
                    "isSequential": true,
                    "activities": [
                        {
                            "name": "Copy1",
                            "type": "Copy",
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "source": {
                                    "type": "FileSystemSource",
                                    "recursive": true
                                },
                                "sink": {
                                    "type": "BlobSink"
                                },
                                "enableStaging": false,
                                "cloudDataMovementUnits": 0
                            },
                            "inputs": [
                                {
                                    "referenceName": "FtpDataset",
                                    "type": "DatasetReference",
                                    "parameters": {
                                        "FtpFileName": "@item().FtpFileName",
                                        "FtpFolderPath": "@item().FtpFolderPath"
                                    }
                                }
                            ],
                            "outputs": [
                                {
                                    "referenceName": "BlobDataset",
                                    "type": "DatasetReference",
                                    "parameters": {
                                        "BlobFileName": "@item().BlobFileName",
                                        "BlobFolderPath": "@item().BlobFolderPath"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "parameters": {
            "InputParams": {
                "type": "Array",
                "defaultValue": [
                    {
                        "FtpFolderPath": "/Folder1/",
                        "FtpFileName": "@concat('File_',formatDateTime(utcnow(), 'yyyyMMdd'), '.txt')",
                        "BlobFolderPath": "blobfolderpath",
                        "BlobFileName": "blobfile1"
                    },
                    {
                        "FtpFolderPath": "/Folder2/",
                        "FtpFileName": "@concat('File_',formatDateTime(utcnow(), 'yyyyMMdd'), '.txt')",
                        "BlobFolderPath": "blobfolderpath",
                        "BlobFileName": "blobfile2"
                    }
                ]
            }
        }
    },
    "type": "Microsoft.DataFactory/factories/pipelines"
}

我遇到的问题是,在指定管道参数时,我似乎无法像为 blob 存储数据集指定文件夹路径那样使用系统变量和函数。 这样做的结果是 formatDateTime(utcnow(), 'yyyyMMdd') 不会被解释为函数调用,而是具有值 formatDateTime(utcnow(), 'yyyyMMdd') 的实际字符串.

为了解决这个问题,我猜测我应该使用触发器来执行管道,并将触发器的执行时间作为参数传递给管道,例如 trigger().startTime 但这是唯一的方法吗?我只是在管道的 JSON 中做错了什么吗?

最佳答案

这应该有效: File_@{formatDateTime(utcnow(), 'yyyyMMdd')}

或者复杂的路径:

rootfolder/subfolder/@{formatDateTime(utcnow(),'yyyy')}/@{formatDateTime(utcnow(),'MM')}/@{formatDateTime(utcnow(),'dd')}/@{formatDateTime(utcnow(),'HH')}

关于使用 utcnow() 作为管道参数的 Azure 数据工厂 v2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50986738/

相关文章:

Azure 数据工厂架构,包含 Azure SQL 数据库到 Power BI

验证失败时 Azure 数据工厂处理结束

azure - 无法从 REST API 获取 Azure 监控指标

azure - 如何使用 Azure CLI 访问 AAD B2C 租户

azure - 在 Azure 函数中使用字体

azure - Microsoft Presidio 支持使用 scala 的 Spark

azure - Azure Data Lake Analytics 上的 E_RUNTIME_SYSTEM_ERROR

Azure 数据工厂 - 如何批量删除数据集?

azure - 如何使用 Azure 数据工厂 GUI 将多个 blob 文件压缩到一个 .gzip 中?

azure - 在数据工厂中使用数据湖分析链接服务服务主体身份验证