azureazure-cosmosdbvnetnetwork-security-groups

Do NSGs apply to Servic Endpoints of the Subnet


I created a Subnet, where I connect a Cosmos DB as Service Endpoint. Besides the IP firewall of the Cosmos DB I want to control the Outbound via NSG rules. However if I create a rule, that denies all Outbound (also tested with deny all Inbound) it seems to have to effect, when connecting to the DB via the Mongo client.

Is this expected behaviour ?


Solution

  • Yes, It's expected behavior when access the Cosmos DB from service endpoint enabled VNet. Here are two points in your question:

    enter image description here

    So, if you are accessing the Cosmos DB from a VNet, it will use the private IP address in that VNet to access the Azure Cosmos DB service. If you are accessing the Cosmos DB outside of Azure, you will be restrcited by the firewall IP address of the Cosmos DB.