Forum Discussion
Step-by-Step Guide to Creating a Cosmos DB with Private DNS in Azure
Introduction: In this blog post, we will walk through the process of creating a Cosmos DB instance with Private DNS in the Azure cloud environment. Private DNS allows you to resolve the Cosmos DB endpoint using a custom domain name within your virtual network, enhancing security and network management. Follow these steps with accompanying screenshots to set up your Cosmos DB with Private DNS.
Prerequisites:
- Azure subscription
- Virtual network created
- Custom domain name
Step 1: Create a Cosmos DB Instance:
1.1. Log in to the Azure portal (https://portal.azure.com/).
1.2. Click on "Create a resource" and search for "Azure Cosmos DB."
1.3. Click "Create" to start the Cosmos DB creation process.
Step 2: Configure Basics:
2.1. Choose the appropriate subscription and resource group.
2.2. Enter a unique name for your Cosmos DB instance.
2.3. Choose the desired API (e.g., Core SQL for SQL API).
2.4. Select the desired location for your Cosmos DB.
Step 3: Networking:
3.1. Under the "Networking" section, select "Enable virtual network."
3.2. Choose the virtual network and subnet where you want to enable Private DNS.
3.3. Click "Next: Advanced" to proceed.
Step 4: Advanced:
4.1. Under the "Advanced" section, select "Enable automatic failover" if needed.
4.2. Enter a unique DNS prefix for your Cosmos DB.
4.3. Configure other advanced settings as necessary.
4.4. Click "Review + Create."
Step 5: Review and Create:
5.1. Review your configuration settings.
5.2. Click "Create" to start the deployment of your Cosmos DB instance.
Step 6: Create Private DNS Zone:
6.1. In the Azure portal, navigate to "Create a resource" and search for "Private DNS Zone."
6.2. Select "Private DNS Zone" and click "Create."
6.3. Choose the subscription and resource group.
6.4. Enter the name of your custom domain (e.g., cosmosprivatedns.local).
6.5. Associate the private DNS zone with the virtual network where your Cosmos DB resides.
Step 7: Add Virtual Network Link:
7.1. Inside the Private DNS Zone you created, go to "Virtual network links" and click "+ Add."
7.2. Select the virtual network where your Cosmos DB is located.
7.3. Choose the subnet associated with your Cosmos DB.
Step 8: Update DNS Configuration in Cosmos DB:
8.1. Go back to your Cosmos DB instance's settings.
8.2. Under "Connection strings," update the "Hostname" with the custom domain name you created in the Private DNS Zone (e.g., mycosmosdb.cosmosprivatedns.local).
Step 9: Test Private DNS Resolution:
9.1. Set up a test application within the same virtual network.
9.2. Use the custom domain name when connecting to the Cosmos DB instance.
9.3. Verify that the connection is successful, indicating the Private DNS resolution is working