Copy data from Snowflake to CosmosDB

Raja 86 Reputation points
2021-06-29T13:24:52.667+00:00

Hi Team,
For one of the requirement I need to copy data from Snowflake to Cosmos DB. Later I want to expose the data using Rest API on top of Cosmos DB (built in feature). But that's for later. Right now my problem is to copy the data.

Since data is simple and does not require much transformation I thought it should be a simple thing to do using ADF. So I plan to use a ADF pipeline and inside pipeline I plan to use Copy Data Activity.

The data in the Snowflake(The source) looks like,

110295-image.png

And the data in the Cosmos DB should look like as below,

{
"id": "123",
"String Col": "Some String",
"Some Ints": [
123,
234
],

After configuring all the basic steps like creating linked service, mapping the columns etc. when I try to publish the pipeline it gives an error,

Direct copying data from Snowflake is only supported when sink dataset is DelimitedText, Parquet or JSON with Azure Blob Storage linked service, for other dataset or linked service, please enable staging

110220-image.png

****Question 1:** Is the copying from Snowflake to Cosmos DB not supported?**

As I understood the answer to above question is "not supported" and to copy the data between these two we need to use an option "staging". Which means a blob storage would be used as temporary staging storage.

****Question 2:** Is my above understanding correct?**

If answer to question #2 is correct then I went ahead and thought to use a existing blob storage. It gives me other error,

110249-image.png

****Question 3:** I really do not understand what should we do now? There's no concrete example as how to retrieve the Sas url to the blob. Does this url need to be pointing to an existing file location?**

****Question 4:** Doing all this to copy just a simple table, is it worth doing it all this? Is this a good solution?**

Helps is highly appreciated.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,846 Reputation points Microsoft Employee Moderator
    2021-06-29T23:28:02.567+00:00

    Hi @Raja ,

    Question 1: Is the copying from Snowflake to Cosmos DB not supported? Question 2: Is my above understanding correct?
    No, it is not supported currently and direct copying from Snowflake to sink is supported (With shared access signature authentication) if the sink is a Azure Blob Storage and sink dataset format is of Parquet, delimited text, or JSON. Please refer to the documentation.

    Question 3: I really do not understand what should we do now? There's no concrete example as how to retrieve the Sas url to the blob. Does this url need to be pointing to an existing file location?
    You need to enable staging as stated in the error message. In order to retrieve SAS URL for the blob you need to go to your blob storage account on azure portal and navigate to "Shared Access Signature" blade. You can configure the required set of permissions this SAS token could contain by selecting "Allowed Services" as Blob/File/Queue/Table. In your case you can select Blob as a service for staging.
    110433-image.png

    You can also define which allowed resource types which could be Service/Container/Object. See below for details around the same.

    Service (s): Access to service-level APIs (e.g., Get/Set Service Properties, Get Service Stats, List Containers/Queues/Tables/Shares)  
Container (c): Access to container-level APIs (e.g., Create/Delete Container, Create/Delete Queue, Create/Delete Table, Create/Delete Share, List Blobs/Files and Directories)  
Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)

    Select Allowed Permissions as Read/Write/Delete/List etc.
    You can select multiple options from above setting as per your requirement.

    For staging (Read/Write) should be enough.
    You can then generate the SAS tokens and use the "SAS Token" from the blade as highlighted above and use it in your linked service like below -
    110422-image.png

    Hope this helps. Please let me know if you have any questions.

    Please refer to the documentation - Staged Copy from Snowflake for any other additional details.

    Thanks
    Saurabh


    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    4: https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview [6]: https://learn.microsoft.com/en-us/azure/data-factory/connector-snowflake#staged-copy-from-snowflake

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.