Cosmos DB Connector
Documentation
Version: 2
Documentation

Write data in Cosmos DB using Cosmos DB Connector in SSIS


In this section we will learn how to configure and use Cosmos DB Connector in the API Destination to write data in the Cosmos DB.

Video Tutorial - Write or lookup data to Cosmos DB using SSIS

This video covers following and more so watch carefully. After watching this video follow the steps described in this article.

  • How to download SSIS PowerPack for Cosmos DB integration in SSIS
  • How to configure connection for Cosmos DB
  • How to Write or lookup data to Cosmos DB
  • Features about SSIS API Destination
  • Using Cosmos DB Connector in SSIS




How to write or lookup data to Cosmos DB in SSIS (Import data)


In upper section we learned how to read data, now in this section we will learn how to configure Cosmos DB in the API Source to Post data to the Cosmos DB.

  1. Read the data from the source, being any desired source component. In example we will use ZappySys Dummy Data Source component.

  2. From the SSIS Toolbox drag and drop API Destination (Predefined Templates) on the Data Flow Designer surface and connect source component with it, and double click to edit it.
    SSIS API Destination (Predefined Templates) - Drag and Drop

  3. Select New Connection to create a new connection:

    API Destination - Cosmos DB
    Connect to your Azure Cosmos DB databases to read, query, create, update, and delete documents and more!
    API Destination - New Connection

  4. Use a preinstalled Cosmos DB Connector from Popular Connector List or press Search Online radio button to download Cosmos DB Connector. Once downloaded simply use it in the configuration:

    Cosmos DB
    Cosmos DB Connector Selection

  5. Proceed with selecting the desired Authentication Type. Then select API Base URL (in most cases default one is the right one). Finally, fill in all the required parameters and set optional parameters if needed. You may press a link Steps to Configure which will help set certain parameters. More info is available in Authentication section.

    Steps to get Cosmos DB Credentials : ApiKey [Http]
    Connecting to your Azure Cosmos DB data requires you to authenticate your REST API access. Follow the instructions below:
    1. Go to your Azure portal homepage: https://portal.azure.com/
    2. In the search bar at the top of the homepage, enter Azure Cosmos DB. In the dropdown that appears, select Azure Cosmos DB.
    3. Click on the name of the database account you want to connect to. (Also copy and paste the name of the database account for later use.)
    4. On the next page where you can see all of the database account information, look along the left side and select Keys.
    5. On the Keys page, you will have two tabs: Read-write Keys and Read-only Keys. If you are going to write data to your database, you need to remain on the Read-write Keys tab. If you are only going to read data from your database, you should select the Read-only Keys tab.
    6. On the Keys page, copy the PRIMARY KEY value and paste it somewhere for later use. (The SECONDARY KEY value may also be copied and pasted instead of PRIMARY KEY.)
    7. Back at the connector screen, enter the primary or secondary key you recorded in step 6 into the Primary or Secondary Key field.
    8. Enter the database account you recorded in step 3 into the Database Account field.
    9. Enter or select the default database you want to connect to using the Defualt Database field.
    10. Enter or select the default table (i.e. container/collection) you want to connect to using the Default Table (Container/Collection) field.
    11. Select the Test Connection button at the bottom of the window to verify proper connectivity with your Azure Devops account.
    12. If the connection test succeeds, select OK.
    Cosmos DB
    ApiKey [Http]
    https://[$Account$].documents.azure.com
    Required Parameters
    Primary or Secondary Key Fill in the parameter...
    Account Name (Case-Sensitive) Fill in the parameter...
    Database Name (keep blank to use default) Case-Sensitive Fill in the parameter...
    API Version Fill in the parameter...
    Optional Parameters
    Default Table (needed to invoke #DirectSQL) Fill in the parameter...
    ZappySys Http Connection

  6. Select the desired endpoint, change/pass the properties values, and go to the Mappings tab to map the columns.

    API Destination - Cosmos DB
    Connect to your Azure Cosmos DB databases to read, query, create, update, and delete documents and more!
    API Destination - Select Endpoint

  7. Finally, map the desired columns:

    API Destination - Cosmos DB
    Connect to your Azure Cosmos DB databases to read, query, create, update, and delete documents and more!
    API Destination - Columns Mapping

  8. That's it; we successfully configured the POST API Call. In a few clicks we configured the Cosmos DB API call using ZappySys Cosmos DB Connector

    Execute Package - Reading data from API Source and load into target