Skip to content

Commit ab0989d

Browse files
Merge pull request #216173 from seesharprun/cosmos-default-credential-table-dotnet
Cosmos DB | Removed DefaultAzureCredential from API for Table + .NET how-to guide
2 parents 3b22442 + 04a9d50 commit ab0989d

File tree

1 file changed

+2
-59
lines changed

1 file changed

+2
-59
lines changed

articles/cosmos-db/table/how-to-dotnet-get-started.md

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ dotnet build
5050

5151
## Connect to Azure Cosmos DB for Table
5252

53-
To connect to the API for Table of Azure Cosmos DB, create an instance of the [``TableServiceClient``](/dotnet/api/azure.data.tables.tableserviceclient) class. This class is the starting point to perform all operations against tables. There are two primary ways to connect to a API for Table account using the **TableServiceClient** class:
53+
To connect to the API for Table of Azure Cosmos DB, create an instance of the [``TableServiceClient``](/dotnet/api/azure.data.tables.tableserviceclient) class. This class is the starting point to perform all operations against tables. There are two primary ways to connect to an API for Table account using the **TableServiceClient** class:
5454

5555
* [Connect with a API for Table connection string](#connect-with-a-connection-string)
56-
* [Connect with Azure Active Directory](#connect-using-the-microsoft-identity-platform)
5756

5857
### Connect with a connection string
5958

@@ -140,62 +139,6 @@ Create a new instance of the **TableServiceClient** class with the ``COSMOS_CONN
140139

141140
:::code language="csharp" source="~/azure-cosmos-db-table-dotnet-v12/101-client-connection-string/Program.cs" id="connection_string" highlight="3":::
142141

143-
### Connect using the Microsoft Identity Platform
144-
145-
To connect to your API for Table account using the Microsoft Identity Platform and Azure AD, use a security principal. The exact type of principal will depend on where you host your application code. The table below serves as a quick reference guide.
146-
147-
| Where the application runs | Security principal
148-
|--|--|---|
149-
| Local machine (developing and testing) | User identity or service principal |
150-
| Azure | Managed identity |
151-
| Servers or clients outside of Azure | Service principal |
152-
153-
#### Import Azure.Identity
154-
155-
The **Azure.Identity** NuGet package contains core authentication functionality that is shared among all Azure SDK libraries.
156-
157-
Import the [Azure.Identity](https://www.nuget.org/packages/Azure.Identity) NuGet package using the ``dotnet add package`` command.
158-
159-
```dotnetcli
160-
dotnet add package Azure.Identity
161-
```
162-
163-
Rebuild the project with the ``dotnet build`` command.
164-
165-
```dotnetcli
166-
dotnet build
167-
```
168-
169-
In your code editor, add using directives for ``Azure.Core`` and ``Azure.Identity`` namespaces.
170-
171-
:::code language="csharp" source="~/azure-cosmos-db-table-dotnet-v12/102-client-default-credential/Program.cs" id="using_identity_directives":::
172-
173-
#### Create TableServiceClient with default credential implementation
174-
175-
If you're testing on a local machine, or your application will run on Azure services with direct support for managed identities, obtain an OAuth token by creating a [``DefaultAzureCredential``](/dotnet/api/azure.identity.defaultazurecredential) instance.
176-
177-
For this example, we saved the instance in a variable of type [``TokenCredential``](/dotnet/api/azure.core.tokencredential) as that's a more generic type that's reusable across SDKs.
178-
179-
:::code language="csharp" source="~/azure-cosmos-db-table-dotnet-v12/102-client-default-credential/Program.cs" id="credential":::
180-
181-
Create a new instance of the **TableServiceClient** class with the ``COSMOS_ENDPOINT`` environment variable and the **TokenCredential** object as parameters.
182-
183-
:::code language="csharp" source="~/azure-cosmos-db-table-dotnet-v12/102-client-default-credential/Program.cs" id="default_credential":::
184-
185-
#### Create TableServiceClient with a custom credential implementation
186-
187-
If you plan to deploy the application out of Azure, you can obtain an OAuth token by using other classes in the [Azure.Identity client library for .NET](/dotnet/api/overview/azure/identity-readme). These other classes also derive from the ``TokenCredential`` class.
188-
189-
For this example, we create a [``ClientSecretCredential``](/dotnet/api/azure.identity.clientsecretcredential) instance by using client and tenant identifiers, along with a client secret.
190-
191-
:::code language="csharp" source="~/azure-cosmos-db-table-dotnet-v12/103-client-secret-credential/Program.cs" id="credential":::
192-
193-
You can obtain the client ID, tenant ID, and client secret when you register an application in Azure Active Directory (AD). For more information about registering Azure AD applications, see [Register an application with the Microsoft identity platform](../../active-directory/develop/quickstart-register-app.md).
194-
195-
Create a new instance of the **TableServiceClient** class with the ``COSMOS_ENDPOINT`` environment variable and the **TokenCredential** object as parameters.
196-
197-
:::code language="csharp" source="~/azure-cosmos-db-table-dotnet-v12/103-client-secret-credential/Program.cs" id="secret_credential":::
198-
199142
## Build your application
200143

201144
As you build your application, your code will primarily interact with four types of resources:
@@ -239,7 +182,7 @@ The following guides show you how to use each of these classes to build your app
239182

240183
## Next steps
241184

242-
Now that you've connected to a API for Table account, use the next guide to create and manage tables.
185+
Now that you've connected to an API for Table account, use the next guide to create and manage tables.
243186

244187
> [!div class="nextstepaction"]
245188
> [Create a table in Azure Cosmos DB for Table using .NET](how-to-dotnet-create-table.md)

0 commit comments

Comments
 (0)