What I have done so far is:
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.
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.