Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Data Factory v2使用utcnow()作为管道参数_Azure_Azure Data Factory_Azure Data Factory 2 - Fatal编程技术网

Azure Data Factory v2使用utcnow()作为管道参数

Azure Data Factory v2使用utcnow()作为管道参数,azure,azure-data-factory,azure-data-factory-2,Azure,Azure Data Factory,Azure Data Factory 2,在上下文中,我目前有一个Data Factory v2管道,其中包含一个调用复制活动的ForEach活动。复制活动仅将数据从FTP服务器复制到blob存储容器 以下是管道json文件: { "name": "pipeline1", "properties": { "activities": [ { "name"

在上下文中,我目前有一个Data Factory v2管道,其中包含一个调用复制活动的ForEach活动。复制活动仅将数据从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(),'yyyyymmdd')
不会被解释为函数调用,而是被解释为值为
formatDateTime(utcnow(),'yyyyymmdd')的实际字符串。


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

您不能将动态表达式放在默认值中。在创建触发器时,或者在复制活动的接收器/源中定义数据集参数时,应该定义此表达式和函数。 所以,要么在源数据集中创建具有某些默认值的数据集属性FtpFileName,然后在复制活动中,可以在源类别中指定该动态表达式


另一种方法是定义管道参数,然后在定义触发器时向该管道参数添加动态表达式。希望这是对您的明确回答。:)

参数的默认值不能是表达式。它们必须是文本字符串。 您可以使用触发器来实现这一点。或者,您可以提取表达式的公共部分,然后将文本值放入foreach项中。

这应该可以:
文件{formatDateTime(utcnow(),'yyyyymmdd')}

或复杂的路径:

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

你好谢谢你的建议。你所说的绝对清楚,我确实在想什么(在创建触发器时指定表达式)。我不想在数据集中使用动态表达式,因为在我的实际用例中,而不仅仅是我给出的示例中,我的文件的格式是FileType1_{Date}.txt或FileType2_{Date}.zip。这意味着有两个参数(文件类型和扩展名)从管道传递到数据集,而不是只有一个参数(文件),其中包含类型、日期和扩展名。是的,我建议您也使用管道参数使用触发器。这些默认值将在运行时被替换。我只是想知道。干杯。我想举一个例子,说明如何传入一个公式,例如
split(myarray,”)[1]
,然后不使用您可以使用的格式
utcnow('yyyyMMdd')