Creating a Cosmos DB

You can create a Cosmos DB using the Azure portal, PowerShell, CLI, and ARM templates. In this demonstration, we are going to create a Cosmos DB server, database, and container from the Azure portal. Therefore, you have to take the following steps:

  1. Navigate to the Azure portal by opening https://portal.azure.com.
  2. Click Create a resource, type Azure Cosmos DB in the search bar and create a new database server.
  3. Add the following values:
    • Subscription: Pick a subscription.
    • Resource group: Create a new one and call it PacktCosmosResourceGroup.
    • Account name: packtsqlapi.
    • API: Core (SQL).
    • Location: East US.
    • Geo-Redundancy: Disable.
    • Multi-region Writes: Disable.
    • Availability ZonesDisable.
  4. Click Review + create and then Create.
  5. When the deployment is finished, open the resource. The Quickstart is automatically opened, and there, you can let Azure automatically create a database and a container, and download a sample app in the language of your choice:

Create a sample application directly from the Azure portal
  1. You can also create your database and container using the Data Explorer. Click Data Explorer in the left menu. In the top menu, click New container. In the Add container blade, add the following values:
    • Database id: PacktToDoList
    • Throughput: 400 (provisioning the throughput at the database level will be shared across unlimited containers)
    • Container id: Items
    • Partition Key: /category
  2. Click OK.

In this demonstration, we created a database server, a database, and container from the Azure portal. In the next section, we are going to create an application that creates a database and container programmatically. Then we will create, read, update, and delete data using the APIs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset