powerbiazure-cosmosdbazure-virtual-networksubnetnetwork-security-groups

How to connect to the cosmos db from power bi desktop application through Azure virtual network


What I have done so far is:

  1. Created Azure Virtual Network.
  2. Created subnet in it and assigned a network security group to that subnet.
  3. In network security group I have added rules to both inbound and outbound to allow traffic from Any source to Any destination.
  4. In cosmos db under 'Firewall and Virtual network' I have 'Selected Networks' turned on and I have added the virtual network and subnet created above.

After trying all above things when I try to connect to cosmos db from power bi desktop application through 'Get Data' option, I am getting following error.

enter image description here


Solution

  • If you have enabled Selected Networks turned on and have added the virtual network and subnet under Firewall and Virtual network. You actually configure the Azure Cosmos account to allow access only from a specific subnet of virtual network (VNet). In the step of limiting access to a subnet within a virtual network, you need to enable the service endpoint for Azure Cosmos DB on the subnet. Read full steps here.

    Furthermore, If you try to connect to cosmos db from power bi desktop application privately, you need to deploy an extra virtual network gateway(VPN) to connect on-premise network to Azure virtual network in your current environment. Otherwise, If not having a VPN gateway, you need to add the outbound public IP ranges of the desktop application to the firewall of Azure Cosmos DB. You can enable both the virtual network service endpoint and an IP access control policy (aka firewall) on your Azure Cosmos account. Read here for more reference.