Skip to content

Commit e2095dd

Browse files
authored
Merge pull request #265747 from alexwolfmsft/cosmos-table-dotnet-quickstart
Update Cosmos Table quickstart for .NET to use azd and codespaces
2 parents 681f905 + df2b5eb commit e2095dd

File tree

6 files changed

+119
-52
lines changed

6 files changed

+119
-52
lines changed

articles/cosmos-db/includes/cosmos-db-create-tableapi-account.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ ms.date: 04/06/2018
99
ms.author: mimig
1010
ms.custom: include file
1111
---
12-
For instructions on creating an Azure Cosmos DB for Table account, see [Create a database account](../table/quickstart-dotnet.md#create-an-azure-cosmos-db-account).
12+
13+
For instructions on creating an Azure Cosmos DB for Table account, see [Create a database account](../how-to-manage-database-account.md).

articles/cosmos-db/table/how-to-create-container.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ This article explains the different ways to create a container in Azure Cosmos D
1919
This article explains the different ways to create a container in Azure Cosmos DB for Table. If you are using a different API, see [API for MongoDB](../mongodb/how-to-create-container.md), [API for Cassandra](../cassandra/how-to-create-container.md), [API for Gremlin](../gremlin/how-to-create-container.md), and [API for NoSQL](../how-to-create-container.md) articles to create the container.
2020

2121
> [!NOTE]
22-
> When creating containers, make sure you dont create two containers with the same name but different casing. Thats because some parts of the Azure platform are not case-sensitive, and this can result in confusion/collision of telemetry and actions on containers with such names.
22+
> When creating containers, make sure you don't create two containers with the same name but different casing. That's because some parts of the Azure platform are not case-sensitive, and this can result in confusion/collision of telemetry and actions on containers with such names.
2323
2424
## <a id="portal-table"></a>Create using Azure portal
2525

2626
1. Sign in to the [Azure portal](https://portal.azure.com/).
2727

28-
1. [Create a new Azure Cosmos DB account](quickstart-dotnet.md#create-an-azure-cosmos-db-account), or select an existing account.
28+
1. [Create a new Azure Cosmos DB account](../how-to-manage-database-account.md), or select an existing account.
2929

3030
1. Open the **Data Explorer** pane, and select **New Table**. Next, provide the following details:
3131

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
author: seesharprun
3+
ms.author: sidandrews
4+
ms.service: cosmos-db
5+
ms.subservice: nosql
6+
ms.topic: include
7+
ms.date: 01/08/2024
8+
ms.custom: include file
9+
zone_pivot_groups: azure-cosmos-db-quickstart-env
10+
---
11+
12+
::: zone pivot="devcontainer-codespace"
13+
14+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
15+
- [GitHub account](https://docs.github.com//get-started/quickstart/creating-an-account-on-github)
16+
17+
::: zone-end
18+
19+
::: zone pivot="devcontainer-vscode"
20+
21+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
22+
- [Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd)
23+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
24+
25+
::: zone-end
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
author: seesharprun
3+
ms.author: sidandrews
4+
ms.service: cosmos-db
5+
ms.subservice: nosql
6+
ms.topic: include
7+
ms.date: 01/08/2024
8+
ms.custom: include file
9+
zone_pivot_groups: azure-cosmos-db-quickstart-env
10+
---
11+
12+
::: zone pivot="devcontainer-codespace"
13+
14+
> [!IMPORTANT]
15+
> GitHub accounts include an entitlement of storage and core hours at no cost. For more information, see [included storage and core hours for GitHub accounts](https://docs.github.com/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#monthly-included-storage-and-core-hours-for-personal-accounts).
16+
17+
::: zone-end
18+
19+
::: zone pivot="devcontainer-vscode"
20+
21+
::: zone-end
22+
23+
1. Open a terminal in the root directory of the project.
24+
25+
1. Authenticate to the Azure Developer CLI using `azd auth login`. Follow the steps specified by the tool to authenticate to the CLI using your preferred Azure credentials.
26+
27+
```azurecli
28+
azd auth login
29+
```
30+
31+
1. Use `azd init` to initialize the project.
32+
33+
```azurecli
34+
azd init
35+
```
36+
37+
1. During initialization, configure a unique environment name.
38+
39+
> [!TIP]
40+
> The environment name will also be used as the target resource group name. For this quickstart, consider using `msdocs-cosmos-db`.
41+
42+
1. Deploy the Azure Cosmos DB account using `azd up`. The Bicep templates also deploy a sample web application.
43+
44+
```azurecli
45+
azd up
46+
```
47+
48+
1. During the provisioning process, select your subscription and desired location. Wait for the provisioning process to complete. The process can take **approximately five minutes**.
49+
50+
1. Once the provisioning of your Azure resources is done, a URL to the running web application is included in the output.
51+
52+
```output
53+
Deploying services (azd deploy)
54+
55+
(✓) Done: Deploying service web
56+
- Endpoint: <https://[container-app-sub-domain].azurecontainerapps.io>
57+
58+
SUCCESS: Your application was provisioned and deployed to Azure in 5 minutes 0 seconds.
59+
```
60+
61+
1. Use the URL in the console to navigate to your web application in the browser. Observe the output of the running app.
62+
63+
:::image type="content" source="../media/cosmos-table-app.png" alt-text="Screenshot of the running web application.":::
153 KB
Loading

articles/cosmos-db/table/quickstart-dotnet.md

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ ms.subservice: table
88
ms.devlang: csharp
99
ms.topic: quickstart
1010
ms.date: 08/22/2022
11-
ms.custom: devx-track-csharp, devguide-csharp, cosmos-db-dev-journey, devx-track-azurecli, devx-track-dotnet
11+
ms.custom: devx-track-csharp, ignite-2022, devguide-csharp, cosmos-db-dev-journey, devx-track-azurecli, devx-track-dotnet, devx-track-extended-azdevcli
12+
zone_pivot_groups: azure-cosmos-db-quickstart-env
1213
---
1314

1415
# Quickstart: Azure Cosmos DB for Table for .NET
@@ -23,7 +24,7 @@ ms.custom: devx-track-csharp, devguide-csharp, cosmos-db-dev-journey, devx-track
2324
> * [Python](quickstart-python.md)
2425
>
2526
26-
This quickstart shows how to get started with the Azure Cosmos DB for Table from a .NET application. The Azure Cosmos DB for Table is a schemaless data store allowing applications to store structured NoSQL data in the cloud. You'll learn how to create tables, rows, and perform basic tasks within your Azure Cosmos DB resource using the [Azure.Data.Tables Package (NuGet)](https://www.nuget.org/packages/Azure.Data.Tables/).
27+
This quickstart shows how to get started with the Azure Cosmos DB for Table from a .NET application. The Azure Cosmos DB for Table is a schemaless data store allowing applications to store structured table data in the cloud. You'll learn how to create tables, rows, and perform basic tasks within your Azure Cosmos DB resource using the [Azure.Data.Tables Package (NuGet)](https://www.nuget.org/packages/Azure.Data.Tables/).
2728

2829
> [!NOTE]
2930
> The [example code snippets](https://github.com/Azure-Samples/cosmos-db-table-api-dotnet-samples) are available on GitHub as a .NET project.
@@ -32,72 +33,49 @@ This quickstart shows how to get started with the Azure Cosmos DB for Table from
3233

3334
## Prerequisites
3435

35-
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).
36-
* [.NET 6.0](https://dotnet.microsoft.com/download)
37-
* [Azure Command-Line Interface (CLI)](/cli/azure/) or [Azure PowerShell](/powershell/azure/)
38-
39-
### Prerequisite check
40-
41-
* In a terminal or command window, run ``dotnet --list-sdks`` to check that .NET 6.x is one of the available versions.
42-
* Run ``az --version`` (Azure CLI) or ``Get-Module -ListAvailable AzureRM`` (Azure PowerShell) to check that you have the appropriate Azure command-line tools installed.
36+
[!INCLUDE[Developer Quickstart prerequisites](includes/dev-prereqs.md)]
4337

4438
## Setting up
4539

46-
This section walks you through how to create an Azure Cosmos DB account and set up a project that uses the API for Table NuGet packages.
47-
48-
### Create an Azure Cosmos DB account
49-
50-
This quickstart will create a single Azure Cosmos DB account using the API for Table.
40+
Deploy this project's development container to your environment. Then, use the Azure Developer CLI (azd) to create an Azure Cosmos DB for Table account and deploy a containerized sample application. The sample application uses the client library to manage, create, read, and query sample data.
5141

52-
#### [Azure CLI](#tab/azure-cli)
42+
::: zone pivot="devcontainer-codespace"
5343

54-
[!INCLUDE [azure-cli-create-resource-group-and-resource](./includes/quickstart-dotnet/azure-cli-create-resource-group-and-resource.md)]
44+
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://codespaces.new/Azure-Samples/cosmos-db-table-dotnet-quickstart?template=false&quickstart=1&azure-portal=true)
5545

56-
#### [PowerShell](#tab/azure-powershell)
46+
::: zone-end
5747

58-
[!INCLUDE [Powershell - create resource group and resources](./includes/quickstart-dotnet/powershell-create-resource-group-and-resource.md)]
48+
::: zone pivot="devcontainer-vscode"
5949

60-
#### [Portal](#tab/azure-portal)
50+
[![Open in Dev Container](https://img.shields.io/static/v1?style=for-the-badge&label=Dev+Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/cosmos-db-table-dotnet-quickstart)
6151

62-
[!INCLUDE [Portal - create resource](./includes/quickstart-dotnet/portal-create-resource.md)]
52+
::: zone-end
6353

64-
---
65-
66-
### Get API for Table connection string
54+
[!INCLUDE[Developer Quickstart setup](includes/dev-setup.md)]
6755

68-
#### [Azure CLI](#tab/azure-cli)
56+
### Install the client library
6957

70-
[!INCLUDE [Azure CLI - get connection string](./includes/quickstart-dotnet/azure-cli-get-connection-string.md)]
58+
The client library is available through NuGet, as the `Microsoft.Azure.Cosmos` package.
7159

72-
#### [PowerShell](#tab/azure-powershell)
60+
1. Open a terminal and navigate to the `/src/web` folder.
7361

74-
[!INCLUDE [Powershell - get connection string](./includes/quickstart-dotnet/powershell-get-connection-string.md)]
62+
```bash
63+
cd ./src/web
64+
```
7565

76-
#### [Portal](#tab/azure-portal)
66+
1. If not already installed, install the `Microsoft.Azure.Cosmos` package using `dotnet add package`.
7767

78-
[!INCLUDE [Portal - get connection string](./includes/quickstart-dotnet/portal-get-connection-string-from-resource.md)]
79-
80-
---
68+
```bash
69+
dotnet add package Microsoft.Azure.Cosmos
70+
```
8171

82-
### Create a new .NET app
83-
84-
Create a new .NET application in an empty folder using your preferred terminal. Use the [``dotnet new console``](/dotnet/core/tools/dotnet-new) to create a new console app.
85-
86-
```console
87-
dotnet new console --output <app-name>
88-
```
89-
90-
### Install the NuGet package
91-
92-
Add the [Azure.Data.Tables](https://www.nuget.org/packages/Azure.Data.Tables) NuGet package to the new .NET project. Use the [``dotnet add package``](/dotnet/core/tools/dotnet-add-package) command specifying the name of the NuGet package.
93-
94-
```console
95-
dotnet add package Azure.Data.Tables
96-
```
72+
1. Also, install the `Azure.Identity` package if not already installed.
9773

98-
### Configure environment variables
74+
```bash
75+
dotnet add package Azure.Identity
76+
```
9977

100-
[!INCLUDE [Multi-tab](./includes/quickstart-dotnet/environment-variables-connection-string.md)]
78+
1. Open and review the **src/web/Cosmos.Samples.Table.Quickstart.Web.csproj** file to validate that the `Microsoft.Azure.Cosmos` and `Azure.Identity` entries both exist.
10179

10280
## Code examples
10381

0 commit comments

Comments
 (0)