使用azure datafactory SSIS将zip文件上载到blob存储的脚本任务
我有一个azure数据工厂项目。我需要从我的Azure SQL数据库中查询一些数据,然后将其加载到xml中,压缩并上传到blob sotrage。我不想向文件系统写入任何内容(因为我认为Azure数据库没有任何lcoal存储),所以我使用Memorystream 此脚本任务正在我的本地SSIS数据库上工作,但不在Azure Datafactory上工作:使用azure datafactory SSIS将zip文件上载到blob存储的脚本任务,azure,ssis,azure-sql-database,azure-storage-blobs,azure-data-factory,Azure,Ssis,Azure Sql Database,Azure Storage Blobs,Azure Data Factory,我有一个azure数据工厂项目。我需要从我的Azure SQL数据库中查询一些数据,然后将其加载到xml中,压缩并上传到blob sotrage。我不想向文件系统写入任何内容(因为我认为Azure数据库没有任何lcoal存储),所以我使用Memorystream 此脚本任务正在我的本地SSIS数据库上工作,但不在Azure Datafactory上工作: using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime;
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,版本=4.3.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(来自HRESULT的异常:0x8013100)
有可能解决这个问题吗?我可以将缺少的dll添加到Azure Datafactory吗?根据本指南,我可以将缺少的dll添加到Azure SSIS IR:
感谢Sandy Winarko(MSFT)的回答