Quickstart: Create an Azure Cosmos DB for MongoDB vCore cluster by using the Azure portal

APPLIES TO: MongoDB vCore

In this quickstart, you create a new Azure Cosmos DB for MongoDB vCore cluster. This cluster contains all of your MongoDB resources: databases, collections, and documents. The cluster provides a unique endpoint for various tools and SDKs to connect to Azure Cosmos DB and perform everyday operations.

Prerequisites

Create a cluster

Create a MongoDB cluster by using Azure Cosmos DB for MongoDB vCore.

Tip

For this guide, we recommend using the resource group name msdocs-cosmos-quickstart-rg.

  1. Sign in to the Azure portal.

  2. From the Azure portal menu or the Home page, select Create a resource.

  3. On the New page, search for and select Azure Cosmos DB.

  4. On the Which API best suits your workload? page, select the Create option within the Azure Cosmos DB for MongoDB section. For more information, see API for MongoDB and it's various models.

    Screenshot of the select API option page for Azure Cosmos DB.

  5. On the Which type of resource? page, select the Create option within the vCore cluster section. For more information, see API for MongoDB vCore overview.

    Screenshot of the select resource type option page for Azure Cosmos DB for MongoDB.

  6. On the Create Azure Cosmos DB for MongoDB cluster page, select the Configure option within the Cluster tier section.

    Screenshot of the configure cluster option for a new Azure Cosmos DB for MongoDB cluster.

  7. On the Scale page, leave the options set to their default values:

    Setting Value
    Shard count Single shard
    Cluster tier M30 Tier, 2 vCores, 8-GiB RAM
    Storage per shard 128 GiB
  8. Leave the High availability option unselected. In the high availability (HA) acknowledgment section, select I understand. Finally, select Save to persist your changes to the cluster tier.

    Screenshot of cluster tier and scale options for a cluster.

  9. Back on the cluster page, enter the following information:

    Setting Value Description
    Subscription Subscription name Select the Azure subscription that you wish to use for this Azure Cosmos DB for MongoDB cluster.
    Resource Group Resource group name Select a resource group, or select Create new, then enter a unique name for the new resource group.
    cluster Name A unique name Enter a name to identify your Azure Cosmos DB for MongoDB cluster. The name is used as part of a fully qualified domain name (FQDN) with a suffix of documents.azure.com, so the name must be globally unique. The name can only contain lowercase letters, numbers, and the hyphen (-) character. The name must also be between 3-44 characters in length.
    Location The region closest to your users Select a geographic location to host your Azure Cosmos DB for MongoDB cluster. Use the location that is closest to your users to give them the fastest access to the data.
    MongoDB version Version of MongoDB to run in your cluster This value is set to a default of 5.0
    Admin username Provide a username to access the cluster This user is created on the cluster as a user administrator.
    Password Use a unique password to pair with the username Password must be at least eight characters and at most 128 characters.

    Screenshot of various configuration options for a cluster.

  10. Select Next: Networking.

  11. In the Networking section, select Allow public access from Azure services. Additionally, add a firewall rule to give your client device or applications access to the cluster.

    Screenshot of networking and firewall options for a cluster.

    Note

    In many corporate environments, developer machine IPs are hidden due to a VPN. In these cases, it's recommended to start with allowing access to all IPs for connection testing initially before refining the allow-list.

  12. Select Review + create.

  13. Review the settings you provide, and then select Create. It takes a few minutes to create the cluster. Wait for the portal page to display Your deployment is complete before moving on.

  14. Select Go to resource to go to the Azure Cosmos DB for MongoDB cluster page.

    Screenshot of the deployment page for a cluster.

Get cluster credentials

Get the connection string you need to connect to this cluster using your application code.

  1. From the Azure Cosmos DB for MongoDB vCore cluster page, select the Connection strings navigation menu option.

    Screenshot of the connection strings option on the page for a cluster.

  2. Record the value from the Connection string field.

    Screenshot of the connection string credential for a cluster.

    Important

    The connection string in the portal does not include the username and password values. You must replace the <user> and <password> placeholders with the credentials you used when you originally created the cluster.

Clean up resources

When you're done with Azure Cosmos DB for MongoDB vCore cluster, you can delete the Azure resources you created so you don't incur more charges.

  1. In the Azure portal search bar, search for and select Resource groups.

  2. In the list, select the resource group you used for this quickstart.

    Screenshot of a list of resource groups filtered down to a specific prefix.

  3. On the resource group page, select Delete resource group.

    Screenshot of the delete resource group option in the menu for a specific resource group.

  4. In the deletion confirmation dialog, enter the name of the resource group to confirm that you intend to delete it. Finally, select Delete to permanently delete the resource group.

    Screenshot of the delete resource group confirmation dialog with the name of the group filled out.

Next step

In this guide, you learned how to create an Azure Cosmos DB for MongoDB vCore cluster. You can now migrate data to your cluster.