Skip to content

Commit 762b1ae

Browse files
committed
Final updates to quickstart
1 parent 0160c46 commit 762b1ae

File tree

5 files changed

+43
-32
lines changed

5 files changed

+43
-32
lines changed

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

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ ms.topic: quickstart
99
ms.date: 02/26/2020
1010
ms.author: dech
1111
---
12+
1213
# Quickstart: Use Node.js to connect and query data from Azure Cosmos DB SQL API account
1314

1415
> [!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)
16+
>
17+
> - [.NET V3](create-sql-api-dotnet.md)
18+
> - [.NET V4](create-sql-api-dotnet-V4.md)
19+
> - [Java](create-sql-api-java.md)
20+
> - [Node.js](create-sql-api-nodejs.md)
21+
> - [Python](create-sql-api-python.md)
22+
> - [Xamarin](create-sql-api-xamarin-dotnet.md)
2123
2224
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.
2325

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

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

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

3840
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.
3941

4042
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.
4143

4244
## Add a container
4345

44-
You can now use the Data Explorer tool in the Azure portal to create a database and container.
46+
You can now use the Data Explorer tool in the Azure portal to create a database and container.
47+
48+
1. Select **Data Explorer** > **New Container**.
4549

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.
50+
The **Add Container** area is displayed on the far right, you may need to scroll right to see it.
4951

50-
![The Azure portal Data Explorer, Add Container pane](./media/create-sql-api-nodejs/azure-cosmosdb-data-explorer.png)
52+
![The Azure portal Data Explorer, Add Container pane](./media/create-sql-api-nodejs/azure-cosmosdb-data-explorer.png)
5153

5254
2. In the **Add container** page, enter the settings for the new container.
5355

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.
56+
| Setting | Suggested value | Description |
57+
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
58+
| **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. |
59+
| **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. |
60+
| **Container ID** | Items | Enter _Items_ as the name for your new container. Container IDs have the same character requirements as database names. |
61+
| **Partition key** | /category | The sample described in this article uses _/category_ as the partition key. |
62+
63+
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.
64+
65+
Select **OK**. The Data Explorer displays the new database and container.
6466

6567
## Add sample data
6668

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

8789
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.
8890

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

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

93107
```javascript
94108
const client = new CosmosClient({ endpoint, key });
@@ -117,8 +131,6 @@ The following snippets are all taken from the _app.js_ file.
117131
const { resources: results } = await container.items
118132
.query(querySpec)
119133
.fetchAll();
120-
121-
return results;
122134
```
123135

124136
- Create a new item
@@ -136,8 +148,6 @@ The following snippets are all taken from the _app.js_ file.
136148
const { resource: itemToUpdate } = await container
137149
.item(id, category)
138150
.replace(itemToUpdate);
139-
140-
return result;
141151
```
142152

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

170180
## Run the app
171181

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

174184
2. Run `node app.js` in a terminal to start your node application.
175185

176-
You can now go back to Data Explorer, modify, and work with this new data.
186+
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.
187+
188+
You can continue to experiment with this sample application or go back to Data Explorer, modify, and work with your data.
177189

178190
## Review SLAs in the Azure portal
179191

@@ -183,5 +195,4 @@ You can now go back to Data Explorer, modify, and work with this new data.
183195

184196
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.
185197

186-
> [!div class="nextstepaction"]
187-
> [Import data into Azure Cosmos DB](import-data.md)
198+
> [!div class="nextstepaction"][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)