Import a .csv to cosmos db

Şükrü Tanrıverdi 0 Reputation points
2023-05-13T11:18:46.1833333+00:00

I have 5 mb csv file and i want to import in azure cosmos db. What is the quickest way to do that.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sangeeta Menon 5 Reputation points
    2023-05-13T11:38:34.4533333+00:00

    One way to import a CSV file into Azure Cosmos DB is to use the Azure Cosmos DB Data Migration tool. Here are the steps you can follow:

    1. Download and install the Azure Cosmos DB Data Migration tool from the Azure Portal.
    2. Open the tool and create a new migration project.
    3. Choose the source type as "CSV" and select the CSV file you want to import.
    4. Choose the target type as "DocumentDB" (the previous name for Azure Cosmos DB).
    5. Enter your Azure Cosmos DB account details and select the appropriate database and collection to import the data into.
    6. Map the fields in your CSV file to the corresponding fields in your Azure Cosmos DB collection.
    7. Review the settings and start the migration.

    The tool will automatically create the appropriate documents in your Azure Cosmos DB collection based on the data in your CSV file. This method is typically faster than manually inserting the data using the Azure Portal or API calls.

    0 comments No comments

  2. RahulRandive 10,486 Reputation points Volunteer Moderator
    2023-05-13T12:11:50.6533333+00:00

    Hi @Şükrü Tanrıverdi

    Thanks for the question.

    If you want automatic import a CSV into a Cosmos DB to update data an Azure Function is the best option for this.

    You can import a CSV in a Cosmos DB over Azure Function

    Here is document for your reference.

    https://github.com/dajor/azurefunction-cosmos

    Blog- https://medium.com/@daniel.jordan/import-a-csv-in-a-cosmos-db-over-azure-function-231880f2ddec

    Thank you!

    0 comments No comments

  3. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2023-05-18T15:33:02.9466667+00:00

    @Şükrü Tanrıverdi

    If you are using NoSQL API the easiest way is to go with Bulk Executor.

    https://learn.microsoft.com/en-us/azure/cosmos-db/bulk-executor-overview

    Regards

    Geetha

    0 comments No comments

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.