Skip to content

Commit 345f120

Browse files
authored
Merge pull request #78646 from ealsur/users/ealsur/connectionmode
Adding Azure Cosmos DB Trigger connection mode article
2 parents 71da574 + 9772a92 commit 345f120

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

articles/cosmos-db/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@
535535
items:
536536
- name: Azure Cosmos DB Trigger logs
537537
href: how-to-configure-cosmos-db-trigger-logs.md
538+
name: Azure Cosmos DB Trigger connection policy
539+
href: how-to-configure-cosmos-db-trigger-connection-policy.md
538540
- name: Multiple Azure Cosmos DB Triggers
539541
href: how-to-create-multiple-cosmos-db-triggers.md
540542
- name: Troubleshoot Azure Cosmos DB Triggers
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Azure Cosmos DB Trigger connection policy
3+
description: Learn how to configure the connection policy used by Azure Cosmos DB Trigger
4+
author: ealsur
5+
ms.service: cosmos-db
6+
ms.topic: sample
7+
ms.date: 06/05/2019
8+
ms.author: maquaran
9+
---
10+
11+
# How to configure the connection policy used by Azure Cosmos DB Trigger
12+
13+
This article describes how you can configure the connection policy when using the Azure Cosmos DB Trigger to connect to your Azure Cosmos account.
14+
15+
## Why is the connection policy important?
16+
17+
There are two connection modes - Direct mode and Gateway mode. To learn more about these connection modes, see the [performance tips](./performance-tips.md#networking) article. By default, **Gateway** is used to establish all connections on the Azure Cosmos DB Trigger. However, it might not be the best option for performance-driven scenarios.
18+
19+
## Changing the connection mode and protocol
20+
21+
There are two key configuration settings available to configure the client connection policy – the **connection mode** and the **connection protocol**. You can change the default connection mode and protocol used by the Azure Cosmos DB Trigger and all the [Azure Cosmos DB bindings](../azure-functions/functions-bindings-cosmosdb-v2.md#output)). To change the default settings, you need to locate the `host.json` file in your Azure Functions project or Azure Functions App and add the following [extra setting](../azure-functions/functions-bindings-cosmosdb-v2.md#hostjson-settings):
22+
23+
```js
24+
{
25+
"cosmosDB": {
26+
"connectionMode": "Direct",
27+
"protocol": "Tcp"
28+
}
29+
}
30+
```
31+
32+
Where `connectionMode` must have the desired connection mode (Direct or Gateway) and `protocol` the desired connection protocol (Tcp or Https).
33+
34+
If your Azure Functions project is working with Azure Functions V1 runtime, the configuration has a slight name difference, you should use `documentDB` instead of `cosmosDB`:
35+
36+
```js
37+
{
38+
"documentDB": {
39+
"connectionMode": "Direct",
40+
"protocol": "Tcp"
41+
}
42+
}
43+
```
44+
45+
> [!NOTE]
46+
> When working with Azure Functions Consumption Plan Hosting plan, each instance has a limit in the amount of Socket Connections that it can maintain. When working with Direct / TCP mode, by design more connections are created and can hit the [Consumption Plan limit](../azure-functions/manage-connections.md#connection-limit), in which case you can either use Gateway mode or run your Azure Functions in [App Service Mode](../azure-functions/functions-scale.md#app-service-plan).
47+
48+
## Next steps
49+
50+
* [Connection limits in Azure Functions](../azure-functions/manage-connections.md#connection-limit)
51+
* [Azure Cosmos DB performance tips](./performance-tips.md)
52+
* [Code samples](https://github.com/ealsur/serverless-recipes/tree/master/connectionmode)

0 commit comments

Comments
 (0)