Setting Metadata key / value in SSIS Amazon S3 / Azure Storage Task

Introduction

In this post we will see how to set Metadata key/value in Azure Blob Storage Task and Amazon Storage Task (S3 Task). We will also see how to set them dynamically at runtime (Use SSIS Expression).

Prerequisites

Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
  1. SSIS designer installed. Sometimes it is referred to as BIDS or SSDT (download it from the Microsoft site).
  2. Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
  3. Make sure ZappySys SSIS PowerPack is installed (download it, if you haven't already).
  4. (Optional step). Read this article, if you are planning to deploy packages to a server and schedule their execution later.

Set Amazon S3 Task Metadata (Key / Value Pairs)

Here is how you can set Metadata in Amazon S3 Task.

Setting Amazon S3 Metadata (Key/Value Pairs) in SSIS Amazon Storage Task

Setting Amazon S3 Metadata (Key/Value Pairs) in SSIS Amazon Storage Task

Set Azure Blob Storage Task Metadata (Key / Value Pairs)

Just like S3 Task you can use same UI in Azure blob storage task too.

Set Metadata Key/Value Dynamically (SSIS Expression)

So far you have set metadata using static value. What if you have to set Dynamically at runtime?

Basically Metadata is passed as XML Format in the task like below.

Whate we will do is take above format and make it dynamic using SSIS Expression.

Perform the following steps for that.

  1. Select your Amazon Storage Task or Azure Storage Task and right click > Select Properties.
  2. In the Properties Grid check Property name MetadataKeyValue. Copy XML Value from there (We will use it in expression)
  3. Now double click Amazon Storage Task or Azure Storage Task
  4. Click on Expression Button
  5. Select MetadataKeyValue property and for Value enter below expression… Use previously copied XML text  and change Value part with your own SSIS variable. In below example we are passing Just one Metadata Key/Value pair ( Name=x-amz-meta-filename  , Value=Coming from @[User::MyFileNameVariable] )
    Note that we have escaped double quote with \"  and replaced static value with <Value>" + @[User::MyFileNameVariable] + "</Value> .
    Set Amazon S3 File Metadata Key/Value dynamically

    Set Amazon S3 File Metadata Key/Value dynamically

  6.  Click OK and that’s it.
Posted in SSIS Amazon Storage Task, SSIS Azure Blob Storage Task and tagged , , , .