You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/service-connector/how-to-integrate-cosmos-db.md
+17-13Lines changed: 17 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
2
2
title: Integrate Azure Cosmos DB for MongoDB with Service Connector
3
-
description: Integrate Azure Cosmos DB for MongoDB into your application with Service Connector
3
+
description: Learn how to integrate Azure Cosmos DB for MongoDB into your application with Service Connector by using the supported authentication methods and clients.
4
4
author: maud-lv
5
5
ms.author: malev
6
6
ms.service: service-connector
7
7
ms.topic: how-to
8
-
ms.date: 03/14/2025
8
+
ms.date: 02/03/2026
9
9
---
10
10
11
11
# Integrate Azure Cosmos DB for MongoDB with Service Connector
12
12
13
-
This page shows supported authentication methods and clients, and shows sample code you can use to connect the Azure Cosmos DB for MongoDB to other cloud services using Service Connector. You might still be able to connect to Azure Cosmos DB for MongoDB in other programming languages without using Service Connector. This page also shows default environment variable names and values (or Spring Boot configuration) you get when you create the service connection.
13
+
This article shows supported authentication methods and clients, and shows sample code you can use to connect the Azure Cosmos DB for MongoDB to other cloud services using Service Connector. You might still be able to connect to Azure Cosmos DB for MongoDB in other programming languages without using Service Connector. This page also shows default environment variable names and values (or Spring Boot configuration) you get when you create the service connection.
14
14
15
15
## Supported compute services
16
16
@@ -24,7 +24,7 @@ Service Connector can be used to connect the following compute services to Azure
24
24
25
25
## Supported authentication types and client types
26
26
27
-
The table below shows which combinations of client types and authentication methods are supported for connecting your compute service to Azure Cosmos DB for MongoDB using Service Connector. A “Yes” indicates that the combination is supported, while a “No” indicates that it is not supported.
27
+
The following table shows which combinations of client types and authentication methods are supported for connecting your compute service to Azure Cosmos DB for MongoDB using Service Connector. A *Yes* indicates that the combination is supported, while a *No* indicates that it isn't supported.
28
28
29
29
| Client type | System-assigned managed identity | User-assigned managed identity | Secret / connection string | Service principal |
@@ -36,14 +36,14 @@ The table below shows which combinations of client types and authentication meth
36
36
| Go | Yes | Yes | Yes | Yes |
37
37
| None | Yes | Yes | Yes | Yes |
38
38
39
-
This table indicates that all combinations of client types and authentication methods in the table are supported, except for the Java - Spring Boot client type, which only supports the Secret / connection string method. All other client types can use any of the authentication methods to connect to Azure Cosmos DB for MongoDB using Service Connector.
39
+
This table indicates that all combinations of client types and authentication methods in the table are supported, except for the Java - Spring Boot client type. This client type only supports the Secret / connection string method. All other client types can use any of the authentication methods to connect to Azure Cosmos DB for MongoDB using Service Connector.
40
40
41
41
> [!NOTE]
42
-
> Cosmos DB does not natively support authentication via managed identity. Therefore, Service Connector uses the managed identity to retrieve the connection string, and the connection is subsequently established using that connection string.
42
+
> Cosmos DB doesn't natively support authentication via managed identity. Therefore, Service Connector uses the managed identity to retrieve the connection string, and the connection is then established using that connection string.
43
43
44
44
## Default environment variable names or application properties and sample code
45
45
46
-
Use the connection details below to connect compute services to Azure Cosmos DB. This page also shows default environment variable names and values (or Spring Boot configuration) you get when you create the service connection, as well as sample code. For each example below, replace the placeholder texts `<mongo-db-admin-user>`, `<password>`, `<Azure-Cosmos-DB-API-for-MongoDB-account>`, `<subscription-ID>`, `<resource-group-name>`, `<client-secret>`, and `<tenant-id>` with your own information. For more information about naming conventions, check the [Service Connector internals](concept-service-connector-internals.md#configuration-naming-convention) article.
46
+
Use the following connection details to connect compute services to Azure Cosmos DB. This page also shows default environment variable names and values (or Spring Boot configuration) you get when you create the service connection, and sample code. For each of these examples, replace the placeholder texts `<mongo-db-admin-user>`, `<password>`, `<Azure-Cosmos-DB-API-for-MongoDB-account>`, `<subscription-ID>`, `<resource-group-name>`, `<client-secret>`, and `<tenant-id>` with your own information. For more information about naming conventions, check the [Service Connector internals](concept-service-connector-internals.md#configuration-naming-convention) article.
47
47
48
48
### System-assigned managed identity
49
49
@@ -55,9 +55,10 @@ Use the connection details below to connect compute services to Azure Cosmos DB.
55
55
56
56
#### Sample code
57
57
58
-
Refer to the steps and code below to connect to Azure Cosmos DB for MongoDB using a system-assigned managed identity.
58
+
To connect to Azure Cosmos DB for MongoDB using a system-assigned managed identity, refer to the following steps and sample code.
59
59
60
60
Since Cosmos DB doesn't natively support authentication via managed identity, in the following code sample, we use the managed identity to retrieve the connection string, and the connection is then established using that connection string.
61
+
61
62
[!INCLUDE [code sample for mongo](./includes/code-cosmosmongo-me-id.md)]
62
63
63
64
### User-assigned managed identity
@@ -71,15 +72,16 @@ Since Cosmos DB doesn't natively support authentication via managed identity, in
71
72
72
73
#### Sample code
73
74
74
-
Refer to the steps and code below to connect to Azure Cosmos DB for MongoDB using a user-assigned managed identity.
75
+
To connect to Azure Cosmos DB for MongoDB using a user-assigned managed identity, refer to the following steps and sample code.
75
76
76
77
Since Cosmos DB doesn't natively support authentication via managed identity, in the following code sample, we use the managed identity to retrieve the connection string, and the connection is then established using that connection string.
78
+
77
79
[!INCLUDE [code sample for mongo](./includes/code-cosmosmongo-me-id.md)]
78
80
79
81
### Connection string
80
82
81
83
> [!WARNING]
82
-
> Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a very high degree of trust in the application, and carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
84
+
> Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a high degree of trust in the application, and carries risks that aren't present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
83
85
84
86
#### Spring Boot client type
85
87
@@ -96,7 +98,8 @@ Since Cosmos DB doesn't natively support authentication via managed identity, in
96
98
97
99
#### Sample code
98
100
99
-
Refer to the steps and code below to connect to Azure Cosmos DB for MongoDB using a connection string.
101
+
To connect to Azure Cosmos DB for MongoDB using a connection string, refer to the following steps and sample code.
102
+
100
103
[!INCLUDE [code sample for mongo](./includes/code-cosmosmongo-secret.md)]
101
104
102
105
### Service principal
@@ -112,12 +115,13 @@ Refer to the steps and code below to connect to Azure Cosmos DB for MongoDB usin
112
115
113
116
#### Sample code
114
117
115
-
Refer to the steps and code below to connect to Azure Cosmos DB for MongoDB using a service principal.
118
+
To connect to Azure Cosmos DB for MongoDB using a service principal, refer to the following steps and sample code.
119
+
116
120
[!INCLUDE [code sample for mongo](./includes/code-cosmosmongo-me-id.md)]
117
121
118
122
## Next steps
119
123
120
-
Follow the tutorials listed below to learn more about Service Connector.
124
+
To learn more about Service Connector, see the following tutorial.
121
125
122
126
> [!div class="nextstepaction"]
123
127
> [Learn about Service Connector concepts](./concept-service-connector-internals.md)
0 commit comments