-2

I have external E2E URL which brings data in JSON format and I wanted to load in Microsoft Azure Cosmos DB.

Can anybody suggest the ways to implement this.

Thanks in advance.

Krish
  • 648
  • 1
  • 8
  • 17
Naveen
  • 115
  • 3
  • 13

2 Answers2

1

Cosmos DB includes a MongoDB API. Are you open to using a library for loading the data? For example, here are a few samples:

Additional sample can be found on the left hand navigation menu on either of these samples.

If not a library, here is an introduction to RESTful interactions with Cosmos DB:

Neil Peterson
  • 282
  • 2
  • 3
1

It sounds like you're looking for something that can call an HTTP endpoint, get a JSON payload and format it to be put into Azure Cosmos DB. You could create an Azure Function with a Cosmos DB output binding. The Azure Function could be triggered on anything you like (a timer, an HTTP endpoint, etc.).

  1. An Azure Function is triggered (see trigger options here) External service calls Azure Function HTTP endpoint, with JSON formatted payload
  2. Azure Function calls external endpoint and receives JSON payload. This post may be helpful: Azure Functions call http post inside function
  3. Azure Function writes to Cosmos DB using output binding (only works with SQL API)

If that's not the kind of advice you're looking for, can you elaborate on your scenario?

Marie Hoeger
  • 1,261
  • 9
  • 11
  • Thnaks Marie Hoeger and let me explain this way i have an end point url and if hit in browser wyth url its returning response in JSON and now i want to call this end point url in Azure and store that response in Cosmo Db. Actually i dont have much idea on Azure. Thanks for your help. – Naveen Aug 08 '18 at 18:27
  • @Naveen - I've updated my answer to reflect your scenario – Marie Hoeger Aug 08 '18 at 18:44
  • Thanks Marie able to get data from rest api using functions but not sure how to integrate with cosmosdb.any suggestions plz. – Naveen Aug 10 '18 at 20:11
  • Just like defining triggers in function.json, you can create "output bindings". Here is some [documentation](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb#output---c-script-examples). Here is also [a tutorial](https://learn.microsoft.com/en-us/azure/azure-functions/functions-integrate-store-unstructured-data-cosmosdb) if you are doing this through the Portal, although we do generally recommend [local development](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-local) – Marie Hoeger Aug 10 '18 at 20:46
  • @Naveen - I should have thought of this earlier, but Logic Apps (in Azure) also may be perfect for you! It lets you define these types of flows (trigger => Http call => output Cosmos) in a really simple way. Here is information on making an [HTTP call](https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http#use-the-http-action), and there is a Preview connector with Cosmos DB. – Marie Hoeger Aug 10 '18 at 23:47