Cosmos DB Connector
Documentation
Version: 2
Documentation

How to read data from Cosmos DB in SSIS (Export data)


In this section we will learn how to configure and use Cosmos DB Connector in the API Source to extract data from the Cosmos DB.

  1. Begin with opening Visual Studio and Create a New Project.

  2. Select Integration Service Project and in new project window set the appropriate name and location for project. And click OK.

  3. In the the new SSIS project screen you will find the following:

    1. SSIS ToolBox on left side bar
    2. Solution Explorer and Property Window on right bar
    3. Control flow, data flow, event Handlers, Package Explorer in tab windows
    4. Connection Manager Window in the bottom
    SSIS Project Screen
    Note: If you don't see ZappySys SSIS PowerPack Task or Components in SSIS Toolbox, please refer to this help link.

  4. Now, Drag and Drop SSIS Data Flow Task from SSIS Toolbox. Double click on the Data Flow Task to see Data Flow designer.
    SSIS Data Flow Task - Drag and Drop

  5. From the SSIS toolbox drag and API Source (Predefined Templates) on the data flow designer surface, and double click on it to edit it:
    SSIS API Source (Predefined Templates) - Drag and Drop

  6. Select New Connection to create a new connection:
    API Source - New Connection

  7. 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

  8. 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

  9. Select the desired endpoint, change/pass the properties values, and click on Preview Data button to make the API call.

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

  10. That's it; we are done. In a few clicks we configured the call to Cosmos DB using ZappySys Cosmos DB Connector