Skip to content

Commit 054f9e5

Browse files
Merge pull request #256885 from wchigit/how-to-cosmos-table
Sample code for integration with Azure Cosmos for Table
2 parents 66ee928 + 32e5ac0 commit 054f9e5

File tree

6 files changed

+320
-34
lines changed

6 files changed

+320
-34
lines changed

articles/service-connector/how-to-integrate-cosmos-table.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ author: maud-lv
55
ms.author: malev
66
ms.service: service-connector
77
ms.topic: how-to
8-
ms.date: 08/11/2022
8+
ms.date: 11/01/2023
99
ms.custom: event-tier1-build-2022, ignite-2022
1010
---
1111

1212
# Integrate the Azure Cosmos DB for Table with Service Connector
1313

14-
This page shows the supported authentication types and client types for the Azure Cosmos DB for Table using Service Connector. You might still be able to connect to the Azure Cosmos DB for Table in other programming languages without using Service Connector. This page also shows default environment variable names and values you get when you create the service connection. You can learn more about [Service Connector environment variable naming convention](concept-service-connector-internals.md).
14+
This page shows supported authentication methods and clients, and shows sample code you can use to connect the Azure Cosmos DB for Table to other cloud services using Service Connector. You might still be able to connect to the Azure Cosmos DB for Table in other programming languages without using Service Connector. This page also shows default environment variable names and values you get when you create the service connection, as well as sample code.
1515

1616
## Supported compute services
1717

@@ -23,46 +23,19 @@ This page shows the supported authentication types and client types for the Azur
2323

2424
Supported authentication and clients for App Service, Container Apps and Azure Spring Apps:
2525

26-
### [Azure App Service](#tab/app-service)
27-
28-
| Client type | System-assigned managed identity | User-assigned managed identity | Secret / connection string | Service principal |
29-
|--------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|
30-
| .NET | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
31-
| Java | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
32-
| Node.js | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
33-
| Python | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
34-
35-
### [Azure Container Apps](#tab/container-apps)
36-
3726
| Client type | System-assigned managed identity | User-assigned managed identity | Secret / connection string | Service principal |
3827
|--------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|
3928
| .NET | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
4029
| Java | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
4130
| Node.js | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
4231
| Python | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
4332

44-
### [Azure Spring Apps](#tab/spring-apps)
45-
46-
| Client type | System-assigned managed identity | User-assigned managed identity | Secret / connection string | Service principal |
47-
|--------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|
48-
| .NET | ![yes icon](./media/green-check.png) | | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
49-
| Java | ![yes icon](./media/green-check.png) | | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
50-
| Node.js | ![yes icon](./media/green-check.png) | | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
51-
| Python | ![yes icon](./media/green-check.png) | | ![yes icon](./media/green-check.png) | ![yes icon](./media/green-check.png) |
52-
5333
---
5434

55-
## Default environment variable names or application properties
56-
57-
Use the connection details below to connect your compute services to the Azure Cosmos DB for Table. For each example below, replace the placeholder texts `<account-name>`, `<table-name>`, `<account-key>`, `<resource-group-name>`, `<subscription-ID>`, `<client-ID>`, `<client-secret>`, `<tenant-id>` with your own information.
35+
## Default environment variable names or application properties and sample code
5836

59-
### Azure App Service and Azure Container Apps
37+
Use the connection details below to connect your compute services to Azure Cosmos DB for Table. For each example below, replace the placeholder texts `<account-name>`, `<table-name>`, `<account-key>`, `<resource-group-name>`, `<subscription-ID>`, `<client-ID>`, `<client-secret>`, `<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.
6038

61-
#### Secret / Connection string
62-
63-
| Default environment variable name | Description | Example value |
64-
|-----------------------------------|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
65-
| AZURE_COSMOS_CONNECTIONSTRING | Azure Cosmos DB for Table connection string | `DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;TableEndpoint=https://<table-name>.table.cosmos.azure.com:443/; ` |
6639

6740
#### System-assigned managed identity
6841

@@ -72,6 +45,11 @@ Use the connection details below to connect your compute services to the Azure C
7245
| AZURE_COSMOS_SCOPE | Your managed identity scope | `https://management.azure.com/.default` |
7346
| AZURE_COSMOS_RESOURCEENDPOINT | Your resource endpoint | `https://<table-name>.documents.azure.com:443/` |
7447

48+
#### Sample code
49+
50+
Refer to the steps and code below to connect to Azure Cosmos DB for Table using a system-assigned managed identity.
51+
[!INCLUDE [code sample for cosmos table](./includes/code-cosmostable-me-id.md)]
52+
7553
#### User-assigned managed identity
7654

7755
| Default environment variable name | Description | Example value |
@@ -81,6 +59,22 @@ Use the connection details below to connect your compute services to the Azure C
8159
| AZURE_COSMOS_CLIENTID | Your client secret ID | `<client-ID>` |
8260
| AZURE_COSMOS_RESOURCEENDPOINT | Your resource endpoint | `https://<table-name>.documents.azure.com:443/` |
8361

62+
#### Sample code
63+
64+
Refer to the steps and code below to connect to Azure Cosmos DB for Table using a user-assigned managed identity.
65+
[!INCLUDE [code sample for cosmos table](./includes/code-cosmostable-me-id.md)]
66+
67+
#### Connection string
68+
69+
| Default environment variable name | Description | Example value |
70+
|-----------------------------------|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71+
| AZURE_COSMOS_CONNECTIONSTRING | Azure Cosmos DB for Table connection string | `DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;TableEndpoint=https://<table-name>.table.cosmos.azure.com:443/; ` |
72+
73+
#### Sample code
74+
75+
Refer to the steps and code below to connect to Azure Cosmos DB for Table using a connection string.
76+
[!INCLUDE [code sample for cosmos table](./includes/code-cosmostable-secret.md)]
77+
8478
#### Service principal
8579

8680
| Default environment variable name | Description | Example value |
@@ -92,6 +86,11 @@ Use the connection details below to connect your compute services to the Azure C
9286
| AZURE_COSMOS_TENANTID | Your tenant ID | `<tenant-ID>` |
9387
| AZURE_COSMOS_RESOURCEENDPOINT | Your resource endpoint | `https://<table-name>.documents.azure.com:443/` |
9488

89+
#### Sample code
90+
91+
Refer to the steps and code below to connect to Azure Cosmos DB for Table using a service principal.
92+
[!INCLUDE [code sample for cosmos table](./includes/code-cosmostable-me-id.md)]
93+
9594
## Next steps
9695

9796
Follow the tutorials listed below to learn more about Service Connector.

articles/service-connector/includes/code-cosmossql-me-id.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Refer to [Build a Spring Data Azure Cosmos DB v3 app to manage Azure Cosmos DB f
101101
### [Python](#tab/python)
102102
1. Install dependencies.
103103
```bash
104+
pip install azure-identity
104105
pip install azure-cosmos
105106
```
106107
1. Authenticate via `azure-identity` library and get the endpoint URL from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
@@ -166,4 +167,4 @@ Refer to [Build a Spring Data Azure Cosmos DB v3 app to manage Azure Cosmos DB f
166167
167168
168169
### [Other](#tab/other)
169-
For other languages, you can use the blob storage account url and other properties that Service Connector set to the environment variables to connect the blob storage. For environment variable details, see [Integrate Azure Blob Storage with Service Connector](../how-to-integrate-storage-blob.md).
170+
For other languages, you can use the endpoint URL and other properties that Service Connector sets to the environment variables to connect to Azure Cosmos DB for NoSQL. For environment variable details, see [Integrate Azure Cosmos DB for NoSQL with Service Connector](../how-to-integrate-cosmos-sql.md).

articles/service-connector/includes/code-cosmossql-secret.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ Refer to [Spring Data Azure Cosmos DB v3 examples](/azure/cosmos-db/nosql/sample
8585
8686
8787
### [Other](#tab/other)
88-
For other languages, you can use the blob storage account URL and other properties that Service Connector set to the environment variables to connect the blob storage. For environment variable details, see [Integrate Azure Blob Storage with Service Connector](../how-to-integrate-storage-blob.md).
88+
For other languages, you can use the endpoint URL and other properties that Service Connector sets to the environment variables to connect to Azure Cosmos DB for NoSQL. For environment variable details, see [Integrate Azure Cosmos DB for NoSQL with Service Connector](../how-to-integrate-cosmos-sql.md).

0 commit comments

Comments
 (0)