You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
*[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.
39
32
40
33
## Create a database account
41
34
@@ -60,11 +53,11 @@ Before you can create a document database, you need to create a SQL API account
60
53
61
54
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.
62
55
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.
@@ -99,7 +92,6 @@ This step is optional. If you're interested in learning how the database resourc
99
92
100
93
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.
101
94
102
-
103
95
1. In the git terminal window, `cd` to the sample code folder.
104
96
105
97
```bash
@@ -123,7 +115,7 @@ Now go back to the Azure portal to get your connection string information and la
123
115
124
116
4. The app creates database with name `AzureSampleFamilyDB`
125
117
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).
127
119
7. The app will query items to retrieve all families with last name in ('Andersen', 'Wakefield', 'Johnson')
128
120
129
121
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
138
130
139
131
## Next steps
140
132
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.
142
134
143
135
> [!div class="nextstepaction"]
144
136
> [Import data into Azure Cosmos DB](import-data.md)
Copy file name to clipboardExpand all lines: articles/cosmos-db/create-sql-api-nodejs.md
+11-14Lines changed: 11 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,16 +20,13 @@ ms.author: dech
20
20
> *[Python](create-sql-api-python.md)
21
21
> *[Xamarin](create-sql-api-xamarin-dotnet.md)
22
22
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.
* [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).
33
30
34
31
## Create a database
35
32
@@ -73,9 +70,9 @@ Now let's clone a Node.js app from GitHub, set the connection string, and run it
73
70
74
71
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).
75
72
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.
77
74
78
-
The following snippets are all taken from the **app.js** file.
75
+
The following snippets are all taken from the *app.js* file.
79
76
80
77
* The `CosmosClient` object is initialized.
81
78
@@ -129,17 +126,17 @@ The following snippets are all taken from the **app.js** file.
129
126
130
127
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.
131
128
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 inthe [Azure portal](https://portal.azure.com/), select**Keys** from the left navigation, and thenselect**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.
133
130
134
131

135
132
136
-
2. In Open the `config.js` file.
133
+
2. In Open the *config.js* file.
137
134
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*.
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.
143
140
144
141
`config.key = "<Your Azure Cosmos account key>"`
145
142
@@ -161,7 +158,7 @@ You can now go back to Data Explorer, modify, and work with this new data.
161
158
162
159
## Next steps
163
160
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.
165
162
166
163
> [!div class="nextstepaction"]
167
164
> [Import data into Azure Cosmos DB](import-data.md)
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).
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.
30
24
31
25
## Prerequisites
32
26
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).
36
32
37
33
## Create a database account
38
34
@@ -71,7 +67,7 @@ You can now use the Data Explorer tool in the Azure portal to create a database
71
67
72
68
## Clone the sample application
73
69
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).
75
71
76
72
1. Open a command prompt, create a new folder named git-samples, then close the command prompt.
77
73
@@ -100,27 +96,27 @@ Now let's clone a SQL API app from GitHub, set the connection string, and run it
100
96
101
97
Now go back to the Azure portal to get your connection string information and copy it into the app.
102
98
103
-
1. In the [Azure portal](https://portal.azure.com/), in your Azure Cosmos account, inthe left navigationselect**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 inthe [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.
104
100
105
101

106
102
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*.
108
104
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*.
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.
114
110
115
111
`key = 'FILLME'`
116
112
117
-
5. Save the ``cosmos_get_started.py`` file.
113
+
5. Save the *cosmos_get_started.py* file.
118
114
119
115
## Review the code
120
116
121
117
This step is optional. Learn about the database resources created in code, or skip ahead to [Update your connection string](#update-your-connection-string).
122
118
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.
124
120
125
121
* 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.
126
122
@@ -155,7 +151,7 @@ The following snippets are all taken from the `cosmos_get_started.py` file.
155
151
156
152
3. Select **View**>**Integrated Terminal** to open the Visual Studio Code integrated terminal.
157
153
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.
@@ -176,36 +172,36 @@ The following snippets are all taken from the `cosmos_get_started.py` file.
176
172
```
177
173
178
174
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:
@@ -217,7 +213,7 @@ The following snippets are all taken from the `cosmos_get_started.py` file.
217
213
218
214
## Next steps
219
215
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 appin Visual Studio Code. You can now import additional data to your Azure Cosmos DB account.
221
217
222
218
> [!div class="nextstepaction"]
223
219
> [Import data into Azure Cosmos DB for the SQL API](import-data.md)
0 commit comments