Hasan Savran takes us through two ways to connect to Cosmos DB:
There are two ways to connect to the Azure Cosmos DB. You need to specify the way you want to connect to Azure Cosmos DB in SDK. The way that you pick for connectivity mode can make a big difference for your application’s performance.
First connectivity mode is Gateway Mode. This is the default way to connect Azure Cosmos DB in earlier version of SDK platforms. This method is mostly for applications that stays behind corporate firewall or It is for environments that have a limited number of socket connections. If your company have strict firewall restrictions, Gateway mode is the way to go for sure. Gateway mode uses standard HTTPS port and single endpoint.
Read on for the second mode, as well as the pros and cons of using each mode.