SQL SSIS包中的Windows Azure蓝色Blob存储

用户名

是否可以将图像从SQL SSIS包上传到Windows Azure二进制存储?SSIS将(每天)从我的本地SQL Server(表)之一读取新图像,并将图像上传到Blob存储。

Billinkc

这是一个多么有趣的问题!我不得不拼凑了很多我从未尝试过的作品。

我首先根据HOW TO:Blob Storage上的详细手册构建了一个简单的控制台应用程序知道我拥有有效的代码后,我便可以将其适应SSIS。

我在程序包级别创建了3个SSIS变量。AccountName,AccountKey和ContainerName。它们都是数据类型String。这些提供凭据+我上传的数据将驻留的文件夹。

数据流和变量

数据流

数据流的总体外观相当简单。脚本组件的数据源,它将充当目标。您将需要两列:一列为Blob提供唯一的名称,另一列为二进制位。

我的资料是一个琐碎的表。它具有国家名称和它们的标志(存储为varbinary(max)),如果您愿意的话,您可以从CIA世界手册中刮取。

目标将是C#。添加类型为“目标”的脚本组件。

在“脚本”选项卡上,我列出了3个ReadOnly变量 User::AccountKey,User::AccountName,User::ContainerName

在“输入列”选项卡上,选择CountryNameFlagImage

脚本本身如下。如操作方法中所述,您将需要添加对Microsoft.WindowsAzure.Storage程序集的引用,然后才能访问那里的最后3个程序集。

using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

// Must add reference to Microsoft.WindowsAzure.Storage for this to work
// http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;

/// <summary>
/// Watch me load data to Azure from SSIS
/// </summary>
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{

    /// <summary>
    /// The storage account used
    /// </summary>
    private CloudStorageAccount storageAccount;

    /// <summary>
    /// An entity to work with the Blobs
    /// </summary>
    private CloudBlobClient blobClient;

    /// <summary>
    /// Blobs live in containers
    /// </summary>
    private CloudBlobContainer container;

    /// <summary>
    /// blockBlob instead of a pageBlob
    /// </summary>
    private CloudBlockBlob blockBlob;

    /// <summary>
    /// This method is called once, before rows begin to be processed in the data flow.
    ///
    /// You can remove this method if you don't need to do anything here.
    /// </summary>
    public override void PreExecute()
    {
        base.PreExecute();
        string cs = string.Empty;
        string csTemplate = string.Empty;
        string accountName = string.Empty;
        string accountKey = string.Empty;
        string containerName = string.Empty;

        accountName = Variables.AccountName;
        accountKey = Variables.AccountKey;
        containerName = Variables.ContainerName;
        csTemplate = "DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}";
        cs = string.Format(csTemplate, accountName, accountKey);

        this.storageAccount = CloudStorageAccount.Parse(cs);
        this.blobClient = this.storageAccount.CreateCloudBlobClient();
        this.container = this.blobClient.GetContainerReference(containerName);
        this.container.CreateIfNotExists();
        this.container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

    }

    /// <summary>
    /// For each row passing through, upload to Azure
    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        string blobName = string.Empty;

        using (MemoryStream memStream = new MemoryStream(Row.FlagImage.GetBlobData(0, (int)Row.FlagImage.Length)))
        {
            this.blockBlob = this.container.GetBlockBlobReference(Row.CountryName);
            this.blockBlob.UploadFromStream(memStream);
        }
    }

}

全局程序集缓存(GAC)

您希望在SSIS中使用的程序集必须驻留在GAC中。除非已签名,否则大会不能进入GAC。幸运的是,对Azure程序集进行了签名,因此可以从Visual Studio命令提示符下键入gacutil -if "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.1\ref\Microsoft.WindowsAzure.Storage.dll"该程序集版本所在的类型或等效版本

加载成功

作为证明,这是Azure存储资源管理器的快照

到处都有斑点

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Azure 函数 - 从 Azure sql server 中的 blob 存储导入 bacpac 文件 - AAD 令牌

来自分类Dev

在带有SSIS包的SQL Server代理作业中找不到存储过程错误

来自分类Dev

如何将作为JSON存储在Azure Blob中的数据加载到Azure SQL数据仓库中?

来自分类Dev

上传存储在Azure Blob存储中的文件

来自分类Dev

哪些Azure SQL产品允许我部署SSIS包?

来自分类Dev

我正在Blob存储中获取连续的Blob文件。我必须加载Databricks并放入Azure SQL DB。数据工厂编排此管道

来自分类Dev

在Azure Blob存储中调整图像大小

来自分类Dev

列出Azure Blob存储中的文件

来自分类Dev

Azure Blob存储中的批量下载

来自分类Dev

在Azure Blob存储中调整图像大小

来自分类Dev

Polybase:Azure Sql DB无法导入Blob存储

来自分类Dev

在 Azure Blob 存储中设置和检索 Blob 的元数据

来自分类Dev

如何在Windows Azure中获取Blob存储的签名?

来自分类Dev

通过查询在SQL Server中创建SSIS包

来自分类Dev

在网站中嵌入存储在Azure BLOB存储中的图像

来自分类Dev

用于在Azure Blob存储中存储图像的共享访问策略

来自分类Dev

从 Excel 读取存储在 Azure Blob 存储中的 .csv

来自分类Dev

如何在SQL Server 2008中存储图像Blob数据?

来自分类Dev

显示在 SQL Server 中存储为 blob 的图像

来自分类Dev

从Azure Blob存储中的Azure函数中加载pickle文件

来自分类Dev

在python的Azure函数中从Azure blob存储读取数据

来自分类Dev

在python的Azure函数中从Azure blob存储读取数据

来自分类Dev

在 Azure PowerShell Runbook 中更改 Azure Blob 存储层

来自分类Dev

仅在Azure Blob存储中列出100个Blob中的10个Blob

来自分类Dev

SQL Server中的SSIS:如何获取它来存储密码

来自分类Dev

使用 Powershell 在 SSIS 包中查找存储过程

来自分类Dev

无法使用 SSIS 从 Azure blob 存储下载页面 blob 类型文件

来自分类Dev

如何连接到Windows 8.1上的Azure blob存储?

来自分类Dev

Windows Azure存储Blob使用Express压缩文件

Related 相关文章

  1. 1

    Azure 函数 - 从 Azure sql server 中的 blob 存储导入 bacpac 文件 - AAD 令牌

  2. 2

    在带有SSIS包的SQL Server代理作业中找不到存储过程错误

  3. 3

    如何将作为JSON存储在Azure Blob中的数据加载到Azure SQL数据仓库中?

  4. 4

    上传存储在Azure Blob存储中的文件

  5. 5

    哪些Azure SQL产品允许我部署SSIS包?

  6. 6

    我正在Blob存储中获取连续的Blob文件。我必须加载Databricks并放入Azure SQL DB。数据工厂编排此管道

  7. 7

    在Azure Blob存储中调整图像大小

  8. 8

    列出Azure Blob存储中的文件

  9. 9

    Azure Blob存储中的批量下载

  10. 10

    在Azure Blob存储中调整图像大小

  11. 11

    Polybase:Azure Sql DB无法导入Blob存储

  12. 12

    在 Azure Blob 存储中设置和检索 Blob 的元数据

  13. 13

    如何在Windows Azure中获取Blob存储的签名?

  14. 14

    通过查询在SQL Server中创建SSIS包

  15. 15

    在网站中嵌入存储在Azure BLOB存储中的图像

  16. 16

    用于在Azure Blob存储中存储图像的共享访问策略

  17. 17

    从 Excel 读取存储在 Azure Blob 存储中的 .csv

  18. 18

    如何在SQL Server 2008中存储图像Blob数据?

  19. 19

    显示在 SQL Server 中存储为 blob 的图像

  20. 20

    从Azure Blob存储中的Azure函数中加载pickle文件

  21. 21

    在python的Azure函数中从Azure blob存储读取数据

  22. 22

    在python的Azure函数中从Azure blob存储读取数据

  23. 23

    在 Azure PowerShell Runbook 中更改 Azure Blob 存储层

  24. 24

    仅在Azure Blob存储中列出100个Blob中的10个Blob

  25. 25

    SQL Server中的SSIS:如何获取它来存储密码

  26. 26

    使用 Powershell 在 SSIS 包中查找存储过程

  27. 27

    无法使用 SSIS 从 Azure blob 存储下载页面 blob 类型文件

  28. 28

    如何连接到Windows 8.1上的Azure blob存储?

  29. 29

    Windows Azure存储Blob使用Express压缩文件

热门标签

归档