Skip to content

Latest commit

 

History

History

azure-cosmosdb-data-as-rest-api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Azure CosmosDB Data as REST API

Use-case

Using this sample, CRUD operations could be used to access the data stored in Azure CosmosDB via REST API.

Prerequisites

Configuration

Create a file called Config.toml at the root of the project.

Config.toml

[<ORG_NAME>.azure_cosmosdb_data_as_rest_api]
baseUrl = "<BASE_URL>"
containerId = "<CONTAINER_ID>"
databaseId = "<DATABASE_ID>"
primaryKeyOrResourceToken = "<TOKEN>"

Run the sample

Run the Ballerina project created by the service sample by executing bal run from the root.

Once successfully executed, listener will run on port 8090. Then you could invoke the service using the following curl commands.

  • To insert an employee
$ curl -v -X POST http://localhost:8090/employees -d '{"empId": "1", firstName" : "Foo", "email": "[email protected]", "designation": "SE"}'
  • To get an employee
$ curl -v -X GET http://localhost:8090/employees/1
  • To update an employee detail
$ curl -v -X PUT http://localhost:8090/employees -d '{"empId": "1", firstName" : "Foo", "email": "[email protected]", "designation": "SSE"}'
  • To delete an employee
$ curl -v -X DELETE http://localhost:8090/employees/1