How to connect to a azure cosmos DB with a private endpoint from a public azure Kubernetes service

Abhishek Singh 381 Reputation points
2023-01-15T11:01:10.9733333+00:00

How to connect to a azure cosmos DB with a private endpoint from a public azure Kubernetes service.

I have a Go application deployed in azure aks (not private) which needs access a private cosmos database. Is there a way to whitelist aks or allow traffic from aks to the database.

Azure Private Link
Azure Private Link
An Azure service that provides private connectivity from a virtual network to Azure platform as a service, customer-owned, or Microsoft partner services.
511 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,643 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,127 questions
{count} votes

2 answers

Sort by: Most helpful
  1. mutaz-msft 2,346 Reputation points Microsoft Employee
    2023-01-15T11:44:57.6133333+00:00

    Hi,
    You can connect by creating a VNET peering between the AKS VNET and the Cosmos DB private endpoint VNET, or by creating a cosmos DB private endpoint using the AKS VNET.

    0 comments No comments

  2. Mark Brown - MSFT 2,766 Reputation points Microsoft Employee
    2023-01-15T16:57:47.6666667+00:00

    We have a reference implementation for building and deploying containerized applications for Azure Kubernetes Service and Azure Cosmos DB. This reference implementation has two flavors, all Bicep and Bicep + Azure Service Operator for Azure Cosmos DB allowing operators to manage Cosmos DB via kubectl.

    The other parts include using KeyVault integrated into secret store, managed service identity (auth/n) with RBAC (auth/z), log analytics for monitoring and also has VNET integration using Service Endpoints (not private endpoints).

    While this doesn't give you exactly everything with private endpoints, it's very close. Just need to configure the private endpoints for Cosmos DB and private DNS for AKS to connect.

    Can start with our blog post on this which walks you through the implementation with links to a GitHub repository you can git clone, modify and deploy yourself.

    Image cosmos todo aks architecture

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.