首页 > 解决方案 > Azure 数据工厂 - 将数据导出到子容器/blob

问题描述

您好我有一个 ADF,可以将 CSV 文件复制(导出 Azure SQL 数据)到一个 blob。如何将文件定向到“子”容器的目的地

我有名为 'SQLdata' 的 blob,我希望在名为 customers 的子容器/blob 中创建文件

我努力了

 "destination": {
                            "fileName": "Customers//Cust1.csv"

以下有什么问题?

   "activities": [
                    {
                        "name": "Export",
                        "type": "Copy",
                        "dependsOn": [],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [
                            {
                                "name": "Source",
                                "value": "dbo.@{item().source.table}"
                            },
                            {
                                "name": "Destination",
                                "value": "@{item().destination.fileName}"
                            }
                        ],




 "parameters": {
            "cw_items": {
                "type": "Array",
                "defaultValue": [
                    {
                        "source": {
                            "table": "Cust1"
                        },
                        "destination": {
                            "fileName": "Cust1.csv"
                        }
                    },
                    {
                        "source": {
                            "table": "Cust2"
                        },
                        "destination": {
                            "fileName": "Cust2.csv"
                        }
                    },

标签: azure

解决方案


我尝试了相同的导出,效果很好,所有 csv 文件都存储在containerleon/csv

JSON 代码参考:

{
    "name": "CopyPipeline_fls",
    "properties": {
        "activities": [
            {
                "name": "ForEach_fls",
                "type": "ForEach",
                "dependsOn": [],
                "userProperties": [],
                "typeProperties": {
                    "items": {
                        "value": "@pipeline().parameters.cw_items",
                        "type": "Expression"
                    },
                    "activities": [
                        {
                            "name": "Copy_fls",
                            "type": "Copy",
                            "dependsOn": [],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false,
                                "secureInput": false
                            },
                            "userProperties": [
                                {
                                    "name": "Source",
                                    "value": "dbo.@{item().source.table}"
                                },
                                {
                                    "name": "Destination",
                                    "value": "containerleon/csv/@{item().destination.fileName}"
                                }
                            ],
                            "typeProperties": {
                                "source": {
                                    "type": "AzureSqlSource"
                                },
                                "sink": {
                                    "type": "DelimitedTextSink",
                                    "storeSettings": {
                                        "type": "AzureBlobStorageWriteSettings"
                                    },
                                    "formatSettings": {
                                        "type": "DelimitedTextWriteSettings",
                                        "quoteAllText": true,
                                        "fileExtension": ".txt"
                                    }
                                },
                                "enableStaging": false
                            },
                            "inputs": [
                                {
                                    "referenceName": "SourceDataset_fls",
                                    "type": "DatasetReference",
                                    "parameters": {
                                        "cw_table": "@item().source.table"
                                    }
                                }
                            ],
                            "outputs": [
                                {
                                    "referenceName": "DestinationDataset_fls",
                                    "type": "DatasetReference",
                                    "parameters": {
                                        "cw_fileName": "@item().destination.fileName"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "parameters": {
            "cw_items": {
                "type": "Array",
                "defaultValue": [
                    {
                        "source": {
                            "table": "test"
                        },
                        "destination": {
                            "fileName": "dbotest.csv"
                        }
                    },
                    {
                        "source": {
                            "table": "test3"
                        },
                        "destination": {
                            "fileName": "dbotest3.csv"
                        }
                    }
                ]
            }
        },
        "annotations": []
    },
    "type": "Microsoft.DataFactory/factories/pipelines"
}

存储预览:

在此处输入图像描述

希望这可以帮助。


推荐阅读