how to store user data in existing cosmos db container?

LALITH SUNDARAM 21 Reputation points
2022-08-02T04:48:51.457+00:00

I am having one website, where user can upload a JSON file about material description, i have to save that file in my cosmos db container(already created), how to do that?

Azure Storage Explorer
Azure Storage Explorer
An Azure tool that is used to manage cloud storage resources on Windows, macOS, and Linux.
231 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,448 questions
{count} votes

Accepted answer
  1. Oury Ba-MSFT 16,471 Reputation points Microsoft Employee
    2022-08-05T21:16:30.653+00:00

    @LALITH SUNDARAM

    Please follow the steps below.

    1. Configure Azure Mongo DB API in Azure
    2. Install the MongoDB https://www.mongodb.com/try/download/database-tools?tck=docs_databasetools&_ga=2.125408073.2137421065.1646329283-587907824.1646329283
    3. Copy the file where the mongodb was install: for my example C:\Program Files\MongoDB\Tools\100\bin
    4. In the shell type cd C:\Program Files\MongoDB\Tools\100\bin press enter then enter the below

    mongoimport --host [insert Host name:10255] -u [Insert username] -p [insert password] --db [insert db name] --collection [collection name] --ssl --type json --writeConcern="{w:0}" --file C:\app\testjsonmongo.json --jsonArray

    Step 5 can be retrieved from your Azure mongo dB

    image.png

    Go back to your cosmos db and check if the files are uploaded.
    For more details please also check this article https://dev.to/azure/uploading-your-json-data-to-azure-cosmos-db-for-mongodb-api-1mh9

    Let me know if you need additional clarification.

    Regards,
    Oury


2 additional answers

Sort by: Most helpful
  1. LALITH SUNDARAM 21 Reputation points
    2022-08-04T04:12:58.463+00:00

    Its MangoDB api, and also pls explain how to read that file from db

    0 comments No comments

  2. LALITH SUNDARAM 21 Reputation points
    2022-08-10T04:51:55.417+00:00

    @Oury Ba-MSFT thanks for your reply, the problem sorted out. I upload and read the files from cosmos