orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Add support of Azure Cosmos DB for MongoDB (vCore)

Open oleksandr-bilyk opened this issue 7 months ago • 0 comments

Please add supports for new Azure Cosmos Db with MongoDB API .NET SDK https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/quickstart-dotnet

All teams that use AKS rely on Workload Identity. It should support Azure.Core.TokenCredential, DefaultAzureCredential and WorkloadIdentityCredential.

This SDK must work in multiple environments:

  1. Localhost Mongo running in docker / docker-compose with basic user password auth.
  2. Minikube hosted Mongo with basic user-password auth.
  3. In future support Aspire
  4. Azure Container App with Managed Identity Auth
  5. AKS in public Azure with Workload Identity in federation with Managed Identity
  6. Azure Local AKS disconnected from azure Workload Identity.

This auth must work with both basic auth and Azure.Core.TokenCredential handles all cases.

Localhost Mongo debugging environment docker-compose looks like this

  # The only local MongoDB replica set with Docker Compose guide you'll ever need!
  # https://anthonysimmon.com/the-only-local-mongodb-replica-set-with-docker-compose-guide-youll-ever-need/
  mongo:
    container_name: mongo
    image: mongo:latest
    command: [
        # Replica set is mandatory for transactions and change streams https://www.mongodb.com/community/forums/t/why-replica-set-is-mandatory-for-transactions-in-mongodb/9533
        "--replSet", "rs0", 
        # bind the MongoDB instance to all IPv4 addresses https://www.mongodb.com/docs/manual/core/security-mongodb-configuration/
        "--bind_ip_all", 
        "--port", "27017" # default port for MongoDB
    ]
    healthcheck:
      # initialize replica set https://anthonysimmon.com/the-only-local-mongodb-replica-set-with-docker-compose-guide-youll-ever-need/
      test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'host.docker.internal:27017'}]}) }" | mongosh --port 27017 --quiet
      interval: 5s
      timeout: 30s
      start_period: 0s
      start_interval: 1s
      retries: 30
    ports:
      - 27017:27017 # MongoDB port
    volumes:
      - ./docker/mongo/data:/data/db # Mongo data storage
    networks:
      - stargate
 
  # Mongo DB Web Portal: https://github.com/mongo-express/mongo-express-docker
  mongo-express:
    container_name: mongo-express
    image: mongo-express:latest
    ports:
    - 7022:8081
    environment:
      ME_CONFIG_MONGODB_URL: mongodb://host.docker.internal:27017/?replicaSet=rs0
      # when you one portal, will have to enter username and password to access it.
      ME_CONFIG_BASICAUTH_USERNAME: admin 
      ME_CONFIG_BASICAUTH_PASSWORD: admin
    depends_on:
      - mongo
    networks:
      - stargate

Thanks @ReubenBond !

oleksandr-bilyk avatar May 30 '25 18:05 oleksandr-bilyk