Skip to content

Commit 11ef1fa

Browse files
Merge pull request #106711 from burkeholland/burke-cosmos-quickstart
Final updates to quickstart
2 parents 4dd3bf3 + 62b25dd commit 11ef1fa

File tree

5 files changed

+41
-31
lines changed

5 files changed

+41
-31
lines changed

articles/cosmos-db/create-sql-api-nodejs.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ ms.author: dech
1212
# Quickstart: Use Node.js to connect and query data from Azure Cosmos DB SQL API account
1313

1414
> [!div class="op_single_selector"]
15-
> * [.NET V3](create-sql-api-dotnet.md)
16-
> * [.NET V4](create-sql-api-dotnet-V4.md)
17-
> * [Java](create-sql-api-java.md)
18-
> * [Node.js](create-sql-api-nodejs.md)
19-
> * [Python](create-sql-api-python.md)
20-
> * [Xamarin](create-sql-api-xamarin-dotnet.md)
15+
> - [.NET V3](create-sql-api-dotnet.md)
16+
> - [.NET V4](create-sql-api-dotnet-V4.md)
17+
> - [Java](create-sql-api-java.md)
18+
> - [Node.js](create-sql-api-nodejs.md)
19+
> - [Python](create-sql-api-python.md)
20+
> - [Xamarin](create-sql-api-xamarin-dotnet.md)
2121
2222
In this quickstart, you create and manage an Azure Cosmos DB SQL API account from the Azure portal, and by using a Node.js app cloned from GitHub. Azure Cosmos DB is a multi-model database service that lets you quickly create and query document, table, key-value, and graph databases with global distribution and horizontal scale capabilities.
2323

@@ -33,34 +33,34 @@ For this quickstart purpose, you can use the [try Azure Cosmos DB for free](http
3333

3434
1. Navigate to the [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) page.
3535

36-
1. Choose the **SQL** API account and select **Create**. Sign-in using your Microsoft account such as outlook.
36+
1. Choose the **SQL** API account and select **Create**. Sign-in using your Microsoft account.
3737

3838
1. After the sign-in is successful, your Azure Cosmos account should be ready. Select **Open in the Azure portal** to open the newly created account.
3939

4040
The "try Azure Cosmos DB for free" option doesn't require an Azure subscription and it offers you an Azure Cosmos account for a limited period of 30 days. If you want to use the Azure Cosmos account for a longer period, you should instead [create the account](create-cosmosdb-resources-portal.md#create-an-azure-cosmos-db-account) within your Azure subscription.
4141

4242
## Add a container
4343

44-
You can now use the Data Explorer tool in the Azure portal to create a database and container.
44+
You can now use the Data Explorer tool in the Azure portal to create a database and container.
4545

46-
1. Select **Data Explorer** > **New Container**.
47-
48-
The **Add Container** area is displayed on the far right, you may need to scroll right to see it.
46+
1. Select **Data Explorer** > **New Container**.
4947

50-
![The Azure portal Data Explorer, Add Container pane](./media/create-sql-api-nodejs/azure-cosmosdb-data-explorer.png)
48+
The **Add Container** area is displayed on the far right, you may need to scroll right to see it.
49+
50+
![The Azure portal Data Explorer, Add Container pane](./media/create-sql-api-nodejs/azure-cosmosdb-data-explorer.png)
5151

5252
2. In the **Add container** page, enter the settings for the new container.
5353

54-
|Setting|Suggested value|Description
55-
|---|---|---|
56-
|**Database ID**|Tasks|Enter *Tasks* as the name for the new database. Database names must contain from 1 through 255 characters, and they cannot contain `/, \\, #, ?`, or a trailing space. Check the **Provision database throughput** option, it allows you to share the throughput provisioned to the database across all the containers within the database. This option also helps with cost savings. |
57-
|**Throughput**|400|Leave the throughput at 400 request units per second (RU/s). If you want to reduce latency, you can scale up the throughput later.|
58-
|**Container ID**|Items|Enter *Items* as the name for your new container. Container IDs have the same character requirements as database names.|
59-
|**Partition key**| /category| The sample described in this article uses */category* as the partition key.|
60-
61-
In addition to the preceding settings, you can optionally add **Unique keys** for the container. Let's leave the field empty in this example. Unique keys provide developers with the ability to add a layer of data integrity to the database. By creating a unique key policy while creating a container, you ensure the uniqueness of one or more values per partition key. To learn more, refer to the [Unique keys in Azure Cosmos DB](unique-keys.md) article.
62-
63-
Select **OK**. The Data Explorer displays the new database and container.
54+
| Setting | Suggested value | Description |
55+
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
56+
| **Database ID** | Tasks | Enter _Tasks_ as the name for the new database. Database names must contain from 1 through 255 characters, and they cannot contain `/, \\, #, ?`, or a trailing space. Check the **Provision database throughput** option, it allows you to share the throughput provisioned to the database across all the containers within the database. This option also helps with cost savings. |
57+
| **Throughput** | 400 | Leave the throughput at 400 request units per second (RU/s). If you want to reduce latency, you can scale up the throughput later. |
58+
| **Container ID** | Items | Enter _Items_ as the name for your new container. Container IDs have the same character requirements as database names. |
59+
| **Partition key** | /category | The sample described in this article uses _/category_ as the partition key. |
60+
61+
In addition to the preceding settings, you can optionally add **Unique keys** for the container. Let's leave the field empty in this example. Unique keys provide developers with the ability to add a layer of data integrity to the database. By creating a unique key policy while creating a container, you ensure the uniqueness of one or more values per partition key. To learn more, refer to the [Unique keys in Azure Cosmos DB](unique-keys.md) article.
62+
63+
Select **OK**. The Data Explorer displays the new database and container.
6464

6565
## Add sample data
6666

@@ -86,9 +86,21 @@ This step is optional. If you're interested in learning how the Azure Cosmos dat
8686

8787
If you're familiar with the previous version of the SQL JavaScript SDK, you may be used to seeing the terms _collection_ and _document_. Because Azure Cosmos DB supports [multiple API models](introduction.md), [version 2.0+ of the JavaScript SDK](https://www.npmjs.com/package/@azure/cosmos) uses the generic terms _container_, which may be a collection, graph, or table, and _item_ to describe the content of the container.
8888

89+
The Cosmos DB JavaScript SDK is called "@azure/cosmos" and can be installed from npm...
90+
91+
```bash
92+
npm install @azure/cosmos
93+
```
94+
8995
The following snippets are all taken from the _app.js_ file.
9096

91-
- The `CosmosClient` object is initialized.
97+
- The `CosmosClient` is imported from the `@azure/cosmos` npm package.
98+
99+
```javascript
100+
const CosmosClient = require("@azure/cosmos").CosmosClient;
101+
```
102+
103+
- A new `CosmosClient` object is initialized.
92104

93105
```javascript
94106
const client = new CosmosClient({ endpoint, key });
@@ -117,8 +129,6 @@ The following snippets are all taken from the _app.js_ file.
117129
const { resources: results } = await container.items
118130
.query(querySpec)
119131
.fetchAll();
120-
121-
return results;
122132
```
123133

124134
- Create a new item
@@ -136,8 +146,6 @@ The following snippets are all taken from the _app.js_ file.
136146
const { resource: itemToUpdate } = await container
137147
.item(id, category)
138148
.replace(itemToUpdate);
139-
140-
return result;
141149
```
142150

143151
- Delete an item
@@ -169,11 +177,13 @@ Now go back to the Azure portal to get the connection string details of your Azu
169177

170178
## Run the app
171179

172-
1. Run `npm install` in a terminal to install required npm modules
180+
1. Run `npm install` in a terminal to install the "@azure/cosmos" npm package
173181

174182
2. Run `node app.js` in a terminal to start your node application.
175183

176-
You can now go back to Data Explorer, modify, and work with this new data.
184+
3. The two items that you created earlier in this quickstart are listed out. A new item is created. The "isComplete" flag on that item is updated to "true" and then finally, the item is deleted.
185+
186+
You can continue to experiment with this sample application or go back to Data Explorer, modify, and work with your data.
177187

178188
## Review SLAs in the Azure portal
179189

@@ -184,4 +194,4 @@ You can now go back to Data Explorer, modify, and work with this new data.
184194
In this quickstart, you've learned how to create an Azure Cosmos DB account, create a container using the Data Explorer, and run a Node.js app. You can now import additional data to your Azure Cosmos DB account.
185195

186196
> [!div class="nextstepaction"]
187-
> [Import data into Azure Cosmos DB](import-data.md)
197+
> [import data into azure cosmos db](import-data.md)

includes/cosmos-db-create-sql-api-query-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
---
1212
You can use queries in Data Explorer to retrieve and filter your data.
1313

14-
1. At the top of the **Documents** tab in Data Explorer, review the default query `SELECT * FROM c`. This query retrieves and displays all documents in the collection in ID order.
14+
1. At the top of the **Items** tab in Data Explorer, review the default query `SELECT * FROM c`. This query retrieves and displays all documents in the collection in ID order.
1515

1616
![Default query in Data Explorer is `SELECT * FROM c`](./media/cosmos-db-create-sql-api-query-data/azure-cosmosdb-data-explorer-query.png)
1717

6.25 KB
Loading
87.8 KB
Loading
80.7 KB
Loading

0 commit comments

Comments
 (0)