如何使用Datafactory管道转换xml数据 [英] How to transform xml data using datafactory pipeline
本文介绍了如何使用Datafactory管道转换xml数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将XML有效内容中的数据保存到Blob存储?
输入
<root>
<alexIsAwesome>yes he is</alexIsAwesome>
<bytes>sdfsdfjijOIJOISJDFQPWORPJkjsdlfkjlksdf==</bytes>
</root>
所需结果
<root>
<alexIsAwesome>yes he is</alexIsAwesome>
<bytes>/blob/path/toSavedPayload</bytes>
</root>
- 将字节保存在blob中的某个地方
- 用保存字节的URI替换字节
我们如何使用数据工厂从XML中提取节点并将其保存到Blob?
推荐答案
由于Azure数据工厂本身不支持XML,所以建议您使用SSIS包.
As Azure Data Factory does not support XML natively, I would suggest you to go for SSIS package.
- 在数据流任务中,具有XML源并将字节从xml中读取到DT_Image数据类型的变量中.
- 创建一个脚本任务,该任务将第1步中获得的字节数组(DT_Image)上载到蔚蓝的Blob存储中,如下所述.根据要求对代码进行了略微修改. SO帖子的引用
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("StorageKey");
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
byte[] byteArrayIn = Dts.Variables["User::ImageVariable"].Value;
// Create or overwrite the "myblob" blob with contents from a local file.
using (var memoryStream = new MemoryStream(byteArrayIn);)
{
blockBlob.UploadFromStream(memoryStream);
}
- 现在,在Azure Data Factory的SSIS运行时中托管此SSIS包并执行SSIS包.
这篇关于如何使用Datafactory管道转换xml数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文