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. Unselect High availability option. 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.

    You can always turn HA on after cluster creation for another layer of protection from failures.

  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 mongocluster.cosmos.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 and 40 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 the latest available MongoDB version.
    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. Leave Access to global distribution (preview) and Free tier unselected.

  11. Select Next: Global distribution (preview).

  12. Select Next: Networking.

  13. In the Firewall rules section on the Networking tab, select Allow public access from Azure services and resources within Azure to this cluster. 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 IP addresses are hidden due to a VPN or other corporate network settings. In these cases, it's recommended to start with allowing access to all IP addresses by adding the 0.0.0.0 - 255.255.255.255 firewall rule for connection testing initially before refining the allow-list.

  14. Select Review + create.

  15. 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.

  16. 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. Copy or record the value from the Connection string field.

    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 entered when you 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.