Skip to content

Commit 47c86c9

Browse files
Merge pull request #102129 from v-thepet/quickstarts2
Three Cosmos DB SQL API quickstarts
2 parents 045aa55 + 396e499 commit 47c86c9

File tree

4 files changed

+67
-82
lines changed

4 files changed

+67
-82
lines changed

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,14 @@ ms.custom: seo-java-august2019, seo-java-september2019
2121
> * [Python](create-sql-api-python.md)
2222
> * [Xamarin](create-sql-api-xamarin-dotnet.md)
2323
24-
This quickstart shows you how to use a Java application to create and manage a document database from your Azure Cosmos DB SQL API account. First, you create an Azure Cosmos DB SQL API account using the Azure portal, create a Java app using the SQL Java SDK, and then add resources to your Cosmos DB account by using the Java application. The instructions in this quickstart can be followed on any operating system that is capable of running Java. After completing this quickstart you'll be familiar with creating and modifying Cosmos DB databases, containers in either the UI or programmatically, whichever is your preference.
24+
In this quickstart, you create and manage an Azure Cosmos DB SQL API account from the Azure portal, and by using a Java app cloned from GitHub. First, you create an Azure Cosmos DB SQL API account using the Azure portal, then create a Java app using the SQL Java SDK, and then add resources to your Cosmos DB account by using the Java application. 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.
2525

2626
## Prerequisites
2727

28-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
29-
[!INCLUDE [cosmos-db-emulator-docdb-api](../../includes/cosmos-db-emulator-docdb-api.md)]
30-
31-
In addition:
32-
33-
* [Java Development Kit (JDK) version 8](https://aka.ms/azure-jdks)
34-
* Be sure to set the JAVA_HOME environment variable to point to the folder where the JDK is installed.
35-
* [Download](https://maven.apache.org/download.cgi) and [install](https://maven.apache.org/install.html) a [Maven](https://maven.apache.org/) binary archive
36-
* On Ubuntu, you can run `apt-get install maven` to install Maven.
37-
* [Git](https://www.git-scm.com/)
38-
* On Ubuntu, you can run `sudo apt-get install git` to install Git.
28+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). Or [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. You can also use the [Azure Cosmos DB Emulator](https://aka.ms/cosmosdb-emulator) with a URI of `https://localhost:8081` and the key `C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==`.
29+
- [Java Development Kit (JDK) 8](https://www.azul.com/downloads/azure-only/zulu/?&version=java-8-lts&architecture=x86-64-bit&package=jdk). Point your `JAVA_HOME` environment variable to the folder where the JDK is installed.
30+
- A [Maven binary archive](https://maven.apache.org/download.cgi). On Ubuntu, run `apt-get install maven` to install Maven.
31+
- [Git](https://www.git-scm.com/downloads). On Ubuntu, run `sudo apt-get install git` to install Git.
3932

4033
## Create a database account
4134

@@ -60,11 +53,11 @@ Before you can create a document database, you need to create a SQL API account
6053

6154
Now let's switch to working with code. Let's clone a SQL API app from GitHub, set the connection string, and run it. You'll see how easy it is to work with data programmatically.
6255

63-
1. Run the following command to clone the sample repository. This command creates a copy of the sample app on your computer.
56+
Run the following command to clone the sample repository. This command creates a copy of the sample app on your computer.
6457

65-
```bash
66-
git clone https://github.com/Azure-Samples/azure-cosmos-java-getting-started.git
67-
```
58+
```bash
59+
git clone https://github.com/Azure-Samples/azure-cosmos-java-getting-started.git
60+
```
6861

6962
## Review the code
7063

@@ -99,7 +92,6 @@ This step is optional. If you're interested in learning how the database resourc
9992

10093
Now go back to the Azure portal to get your connection string information and launch the app with your endpoint information. This enables your app to communicate with your hosted database.
10194

102-
10395
1. In the git terminal window, `cd` to the sample code folder.
10496

10597
```bash
@@ -123,7 +115,7 @@ Now go back to the Azure portal to get your connection string information and la
123115

124116
4. The app creates database with name `AzureSampleFamilyDB`
125117
5. The app creates container with name `FamilyContainer`
126-
6. The app will perform point reads using object ids and partition key value (which is lastName in our sample).
118+
6. The app will perform point reads using object IDs and partition key value (which is lastName in our sample).
127119
7. The app will query items to retrieve all families with last name in ('Andersen', 'Wakefield', 'Johnson')
128120

129121
7. The app doesn't delete the created resources. Switch back to the portal to [clean up the resources](#clean-up-resources). from your account so that you don't incur charges.
@@ -138,7 +130,7 @@ Now go back to the Azure portal to get your connection string information and la
138130

139131
## Next steps
140132

141-
In this quickstart, you've learned how to create an Azure Cosmos account, document database, and container using the Data Explorer, and run an app to do the same thing programmatically. You can now import additional data into your Azure Cosmos container.
133+
In this quickstart, you've learned how to create an Azure Cosmos DB SQL API account, create a document database and container using the Data Explorer, and run a Java app to do the same thing programmatically. You can now import additional data into your Azure Cosmos DB account.
142134
143135
> [!div class="nextstepaction"]
144136
> [Import data into Azure Cosmos DB](import-data.md)

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ ms.author: dech
2020
> * [Python](create-sql-api-python.md)
2121
> * [Xamarin](create-sql-api-xamarin-dotnet.md)
2222
23-
This quickstart demonstrates how to use a Node.js app to connect to the [SQL API](sql-api-introduction.md) account in Azure Cosmos DB. You can then use Azure Cosmos DB SQL queries to query and manage data. The Node.js app you build in this article uses the [SQL JavaScript SDK](sql-api-sdk-node.md). This quickstart uses version 2.0 of the [JavaScript SDK](https://www.npmjs.com/package/@azure/cosmos).
23+
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.
2424

2525
## Prerequisites
2626

27-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
28-
[!INCLUDE [cosmos-db-emulator-docdb-api](../../includes/cosmos-db-emulator-docdb-api.md)]
29-
30-
* In addition:
31-
* [Node.js](https://nodejs.org/en/) version v6.0.0 or higher
32-
* [Git](https://git-scm.com/)
27+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). Or [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. You can also use the [Azure Cosmos DB Emulator](https://aka.ms/cosmosdb-emulator) with a URI of `https://localhost:8081` and the key `C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==`.
28+
- [Node.js 6.0.0+](https://nodejs.org/).
29+
- [Git](https://www.git-scm.com/downloads).
3330

3431
## Create a database
3532

@@ -73,9 +70,9 @@ Now let's clone a Node.js app from GitHub, set the connection string, and run it
7370

7471
This step is optional. If you're interested in learning how the Azure Cosmos database resources are created in the code, you can review the following snippets. Otherwise, you can skip ahead to [Update your connection string](#update-your-connection-string).
7572
76-
Note, if you are familiar with the previous version of the JavaScript SDK, you may be used to seeing the terms 'collection' and 'document.' Because Azure Cosmos DB supports [multiple API models](https://docs.microsoft.com/azure/cosmos-db/introduction), version 2.0+ of the JavaScript SDK uses the generic terms 'container', which may be a collection, graph, or table and 'item' to describe the content of the container.
73+
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.
7774

78-
The following snippets are all taken from the **app.js** file.
75+
The following snippets are all taken from the *app.js* file.
7976

8077
* The `CosmosClient` object is initialized.
8178

@@ -129,17 +126,17 @@ The following snippets are all taken from the **app.js** file.
129126
130127
Now go back to the Azure portal to get the connection string details of your Azure Cosmos account. Copy the connection string into the app so that it can connect to your database.
131128
132-
1. In the [Azure portal](https://portal.azure.com/), in your Azure Cosmos account, in the left navigation click **Keys**, and then click **Read-write Keys**. You'll use the copy buttons on the right side of the screen to copy the URI and Primary Key into the `config.js` file in the next step.
129+
1. In your Azure Cosmos DB account in the [Azure portal](https://portal.azure.com/), select **Keys** from the left navigation, and then select **Read-write Keys**. Use the copy buttons on the right side of the screen to copy the URI and Primary Key into the *config.js* file in the next step.
133130
134131
![View and copy an access key in the Azure portal, Keys blade](./media/create-sql-api-dotnet/keys.png)
135132
136-
2. In Open the `config.js` file.
133+
2. In Open the *config.js* file.
137134
138-
3. Copy your URI value from the portal (using the copy button) and make it the value of the endpoint key in `config.js`.
135+
3. Copy your URI value from the portal (using the copy button) and make it the value of the endpoint key in *config.js*.
139136
140137
`config.endpoint = "<Your Azure Cosmos account URI>"`
141138
142-
4. Then copy your PRIMARY KEY value from the portal and make it the value of the `config.key` in `config.js`. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
139+
4. Then copy your PRIMARY KEY value from the portal and make it the value of the `config.key` in *config.js*. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
143140
144141
`config.key = "<Your Azure Cosmos account key>"`
145142
@@ -161,7 +158,7 @@ You can now go back to Data Explorer, modify, and work with this new data.
161158
162159
## Next steps
163160
164-
In this quickstart, you've learned how to create an Azure Cosmos account, create a container using the data explorer, and run an app. You can now import additional data to your Azure Cosmos database.
161+
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.
165162
166163
> [!div class="nextstepaction"]
167164
> [Import data into Azure Cosmos DB](import-data.md)

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

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@ ms.custom: [seodec18, seo-javascript-september2019, seo-python-october2019]
2020
> * [Python](create-sql-api-python.md)
2121
> * [Xamarin](create-sql-api-xamarin-dotnet.md)
2222
23-
This quickstart demonstrates how to create an Azure Cosmos DB [SQL API](sql-api-introduction.md) account, document database, and container using the Azure portal. You then build and run a console app built with the Python SDK for [SQL API](sql-api-sdk-python.md).
24-
25-
Azure Cosmos DB is Microsoft’s globally distributed multi-model database service. You can quickly create and query documents, key/value, wide column and graph databases. All of these operations benefit from the distribution and scale of Azure Cosmos DB.
26-
27-
This quickstart uses version 4 of the [Python SDK](https://pypi.org/project/azure-cosmos/#history).
28-
29-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)] [!INCLUDE [cosmos-db-emulator-docdb-api](../../includes/cosmos-db-emulator-docdb-api.md)]
23+
In this quickstart, you create and manage an Azure Cosmos DB SQL API account from the Azure portal, and from Visual Studio Code with a Python 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.
3024

3125
## Prerequisites
3226

33-
* [Python 3.6+](https://www.python.org/downloads/), with the `python` executable available in your `PATH`.
34-
* [Visual Studio Code](https://code.visualstudio.com/)
35-
* [Python extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python#overview)
27+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). Or [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. You can also use the [Azure Cosmos DB Emulator](https://aka.ms/cosmosdb-emulator) with a URI of `https://localhost:8081` and the key `C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==`.
28+
- [Python 3.6+](https://www.python.org/downloads/), with the `python` executable in your `PATH`.
29+
- [Visual Studio Code](https://code.visualstudio.com/).
30+
- The [Python extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python#overview).
31+
- [Git](https://www.git-scm.com/downloads).
3632

3733
## Create a database account
3834

@@ -71,7 +67,7 @@ You can now use the Data Explorer tool in the Azure portal to create a database
7167

7268
## Clone the sample application
7369

74-
Now let's clone a SQL API app from GitHub, set the connection string, and run it.
70+
Now let's clone a SQL API app from GitHub, set the connection string, and run it. This quickstart uses version 4 of the [Python SDK](https://pypi.org/project/azure-cosmos/#history).
7571

7672
1. Open a command prompt, create a new folder named git-samples, then close the command prompt.
7773

@@ -100,27 +96,27 @@ Now let's clone a SQL API app from GitHub, set the connection string, and run it
10096

10197
Now go back to the Azure portal to get your connection string information and copy it into the app.
10298

103-
1. In the [Azure portal](https://portal.azure.com/), in your Azure Cosmos account, in the left navigation select **Keys**. You'll use the copy buttons on the right side of the screen to copy the **URI** and **Primary Key** into the `cosmos_get_started.py` file in the next step.
99+
1. In your Azure Cosmos DB account in the [Azure portal](https://portal.azure.com/), select **Keys** from the left navigation. Use the copy buttons on the right side of the screen to copy the **URI** and **Primary Key** into the *cosmos_get_started.py* file in the next step.
104100

105101
![Get an access key and URI in the Keys settings in the Azure portal](./media/create-sql-api-dotnet/access-key-and-uri-in-keys-settings-in-the-azure-portal.png)
106102

107-
2. Open the `cosmos_get_started.py` file in \git-samples\azure-cosmos-db-python-getting-started in Visual Studio Code.
103+
2. In Visual Studio Code, open the *cosmos_get_started.py* file in *\git-samples\azure-cosmos-db-python-getting-started*.
108104

109-
3. Copy your **URI** value from the portal (using the copy button) and make it the value of the **endpoint** variable in ``cosmos_get_started.py``.
105+
3. Copy your **URI** value from the portal (using the copy button) and make it the value of the **endpoint** variable in *cosmos_get_started.py*.
110106

111107
`endpoint = 'https://FILLME.documents.azure.com',`
112108

113-
4. Then copy your **PRIMARY KEY** value from the portal and make it the value of the **key** in ``cosmos_get_started.py``. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
109+
4. Then copy your **PRIMARY KEY** value from the portal and make it the value of the **key** in *cosmos_get_started.py*. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
114110
115111
`key = 'FILLME'`
116112
117-
5. Save the ``cosmos_get_started.py`` file.
113+
5. Save the *cosmos_get_started.py* file.
118114
119115
## Review the code
120116
121117
This step is optional. Learn about the database resources created in code, or skip ahead to [Update your connection string](#update-your-connection-string).
122118
123-
The following snippets are all taken from the `cosmos_get_started.py` file.
119+
The following snippets are all taken from the *cosmos_get_started.py* file.
124120
125121
* The CosmosClient is initialized. Make sure to update the "endpoint" and "key" values as described in the [Update your connection string](#update-your-connection-string) section.
126122
@@ -155,7 +151,7 @@ The following snippets are all taken from the `cosmos_get_started.py` file.
155151

156152
3. Select **View** > **Integrated Terminal** to open the Visual Studio Code integrated terminal.
157153

158-
4. In the integrated terminal window, ensure you are in the azure-cosmos-db-python-getting-started folder. If not, run the following command to switch to the sample folder.
154+
4. In the integrated terminal window, ensure you are in the *azure-cosmos-db-python-getting-started* folder. If not, run the following command to switch to the sample folder.
159155

160156
```cmd
161157
cd "\git-samples\azure-cosmos-db-python-getting-started"`
@@ -176,36 +172,36 @@ The following snippets are all taken from the `cosmos_get_started.py` file.
176172
```
177173
178174
7. To confirm the new items were created and saved, in the Azure portal, select **Data Explorer** > **AzureSampleFamilyDatabase** > **Items**. View the items that were created. For example, here is a sample JSON document for the Andersen family:
179-
180-
```json
181-
{
182-
"id": "Andersen-1569479288379",
183-
"lastName": "Andersen",
184-
"district": "WA5",
185-
"parents": [
186-
{
187-
"familyName": null,
188-
"firstName": "Thomas"
189-
},
190-
{
191-
"familyName": null,
192-
"firstName": "Mary Kay"
193-
}
194-
],
195-
"children": null,
196-
"address": {
197-
"state": "WA",
198-
"county": "King",
199-
"city": "Seattle"
200-
},
201-
"registered": true,
202-
"_rid": "8K5qAIYtZXeBhB4AAAAAAA==",
203-
"_self": "dbs/8K5qAA==/colls/8K5qAIYtZXc=/docs/8K5qAIYtZXeBhB4AAAAAAA==/",
204-
"_etag": "\"a3004d78-0000-0800-0000-5d8c5a780000\"",
205-
"_attachments": "attachments/",
206-
"_ts": 1569479288
207-
}
208-
```
175+
176+
```json
177+
{
178+
"id": "Andersen-1569479288379",
179+
"lastName": "Andersen",
180+
"district": "WA5",
181+
"parents": [
182+
{
183+
"familyName": null,
184+
"firstName": "Thomas"
185+
},
186+
{
187+
"familyName": null,
188+
"firstName": "Mary Kay"
189+
}
190+
],
191+
"children": null,
192+
"address": {
193+
"state": "WA",
194+
"county": "King",
195+
"city": "Seattle"
196+
},
197+
"registered": true,
198+
"_rid": "8K5qAIYtZXeBhB4AAAAAAA==",
199+
"_self": "dbs/8K5qAA==/colls/8K5qAIYtZXc=/docs/8K5qAIYtZXeBhB4AAAAAAA==/",
200+
"_etag": "\"a3004d78-0000-0800-0000-5d8c5a780000\"",
201+
"_attachments": "attachments/",
202+
"_ts": 1569479288
203+
}
204+
```
209205
210206
## Review SLAs in the Azure portal
211207
@@ -217,7 +213,7 @@ The following snippets are all taken from the `cosmos_get_started.py` file.
217213
218214
## Next steps
219215
220-
In this quickstart, you've learned how to create an Azure Cosmos account, create a container using the Data Explorer, and run an app. You can now import additional data to your Cosmos DB account.
216+
In this quickstart, you've learned how to create an Azure Cosmos DB account, create a container using the Data Explorer, and run a Python app in Visual Studio Code. You can now import additional data to your Azure Cosmos DB account.
221217
222218
> [!div class="nextstepaction"]
223219
> [Import data into Azure Cosmos DB for the SQL API](import-data.md)
-17.4 KB
Loading

0 commit comments

Comments
 (0)