Gateway Mode

From Ilianko
Revision as of 15:07, 26 October 2026 by Anko (talk | contribs) (Recreated DP-420 term page: Gateway Mode (Client Connectivity & SDK))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

← Back to DP-420 Terminology Reference

Category: Client Connectivity & SDK

Summary: SDK connectivity via a single HTTPS endpoint; more firewall-friendly, higher latency.

Overview

Gateway mode is an Azure Cosmos DB SDK connectivity mode where all requests are routed through a single HTTPS endpoint (the gateway), which forwards them to the appropriate backend replica. It works through firewalls/proxies more easily than direct mode since it uses standard HTTPS on port 443, but generally has slightly higher latency due to the extra network hop.

//one liner
new CosmosClient(endpoint, key, new CosmosClientOptions { ConnectionMode = ConnectionMode.Gateway })        

//multi-liner
CosmosClientOptions clientOptions = new CosmosClientOptions()
{
    ConnectionMode = ConnectionMode.Gateway
};

using CosmosClient client = new CosmosClient(endpoint, key, clientOptions);
try
{
    AccountProperties accountProperties = await client.ReadAccountAsync();
    // Your application logic here
}
catch (Exception ex)
{
    Console.Error.WriteLine(ex.Message);
}

More Info & Links

DP-420 Style Practice Questions

Q1. What is a key advantage of gateway mode over direct mode?

  • A. Easier compatibility with firewalls and proxies since it uses standard HTTPS on port 443
  • B. Lower latency than direct mode
  • C. No RU cost for requests
  • D. Automatic multi-region writes

Q2. Why might gateway mode have higher latency than direct mode?

  • A. Requests are routed through an extra network hop via the gateway before reaching the backend replica
  • B. Gateway mode disables indexing
  • C. Gateway mode only supports serverless accounts
  • D. Gateway mode requires synchronous replication

Answer Key

Answers are listed at the very end so you can attempt the questions first.

  • Q1 (Gateway Mode): A. Easier compatibility with firewalls and proxies since it uses standard HTTPS on port 443 — Gateway mode uses a single HTTPS endpoint on port 443, making it easier to work with restrictive network/firewall configurations.
  • Q2 (Gateway Mode): A. Requests are routed through an extra network hop via the gateway before reaching the backend replica — Gateway mode adds an additional hop through the gateway service, which can increase latency compared to direct mode.

DP-420: Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB — term detail page