gpt4 book ai didi

azure - 使用 azure datafactory SSIS 将 zip 文件上传到 blob 存储的脚本任务

转载 作者:行者123 更新时间:2023-12-02 06:46:25 25 4
gpt4 key购买 nike

我有一个 azure 数据工厂项目。我需要从 Azure SQL 数据库查询一些数据,然后加载到 xml 中,将其压缩并上传到 blob sotrage。我不想向文件系统写入任何内容(因为我认为 Azure 数据库没有任何 lcoal 存储),因此我使用 Memorystream。

此脚本任务适用于我的本地 SSIS 数据库,但不适用于 Azure Datafactory:

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Collections;
using System.Linq;
using System.Data.OleDb;
using System.IO;

using System.IO.Compression;
using System.Data.SqlClient;
using Microsoft.Azure;

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;


public void Main()
{

CloudStorageAccount storageAccount = null;
CloudBlobContainer cloudBlobContainer = null;


try
{

DataSet ds = new DataSet("FullList");
OleDbDataAdapter oleDa = new OleDbDataAdapter();

DataTable dt = new DataTable("CustomerTable");
oleDa.Fill(dt, Dts.Variables["User::CustomerSelect"].Value);
ds.Tables.Add(dt);

DataTable dt_product = new DataTable("ProductTable");
oleDa.Fill(dt_product, Dts.Variables["User::ProductSelect"].Value);
ds.Tables.Add(dt_product);



DataRelation relation = ds.Relations.Add("relation", ds.Tables["CustomerTable"].Columns["id"], ds.Tables["ProductTable"].Columns["id"]);
relation.Nested = true;


string connstring = Dts.Connections["testolgdev"].AcquireConnection(Dts.Transaction).ToString();
if (CloudStorageAccount.TryParse(connstring, out storageAccount))
{
try
{
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();


cloudBlobContainer = cloudBlobClient.GetContainerReference("flat");

string fileName = "xml" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".zip";
var blob = cloudBlobContainer.GetBlockBlobReference(fileName);
using (var stream = new ZipArchive(blob.OpenWrite(), ZipArchiveMode.Create))
{
var entry = stream.CreateEntry("test_dataset_fullresult_onlymem.xml");
using (var es = entry.Open())
{
ds.WriteXml(es);
}


}



}
catch (StorageException ex)
{
Console.WriteLine("Error returned from the service: {0}", ex.Message);
}
}
else
{
Console.WriteLine("Wrong connection string");
}



}
catch (TargetInvocationException e)
{

throw;
}

Dts.TaskResult = (int)ScriptResults.Success;
}

这是我部署和执行时出现的 Azure Datafactory SSIS 错误:

脚本任务 1:错误:无法加载文件或程序集“Microsoft.WindowsAzure.Storage,Version=4.3.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。找到的程序集的 list 定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)

这个问题可以解决吗?我可以将缺少的 dll 添加到 Azure Datafactory 吗?

最佳答案

通过本指南,我可以将缺少的 dll 添加到 Azure-SSIS IR:
https://learn.microsoft.com/en-us/azure/data-factory/how-to-configure-azure-ssis-ir-custom-setup.

感谢Sandy Winarko(MSFT)的回答!

关于azure - 使用 azure datafactory SSIS 将 zip 文件上传到 blob 存储的脚本任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50209142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com