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
Azure Cosmos DB is Microsoft’s globally distributed multi-model database service. Using Azure Cosmos DB, you can quickly create and query managed document, table, and graph databases.
26
-
27
-
This quickstart creates a simple graph database using the Azure portal tools for Azure Cosmos DB. This quickstart also shows you how to quickly create a Java console app using a [Gremlin API](graph-introduction.md) database using the OSS [Apache TinkerPop](https://tinkerpop.apache.org/) driver. The instructions in this quickstart can be followed on any operating system that is capable of running Java. This quickstart familiarizes you with creating and modifying graphs in either the UI or programmatically, whichever is your preference.
25
+
In this quickstart, you create and manage an Azure Cosmos DB Gremlin (graph) API account from the Azure portal, and add data by using a Java 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.
*[Java Development Kit (JDK) version 8](https://aka.ms/azure-jdks)
35
-
* Be sure to set the JAVA_HOME environment variable to point to the folder where the JDK is installed.
36
-
*[Download](https://maven.apache.org/download.cgi) and [install](https://maven.apache.org/install.html) a [Maven](https://maven.apache.org/) binary archive
37
-
* On Ubuntu, you can run `apt-get install maven` to install Maven.
38
-
*[Git](https://www.git-scm.com/)
39
-
* 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).
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).
31
+
-[Git](https://www.git-scm.com/downloads).
40
32
41
33
## Create a database account
42
34
@@ -74,17 +66,19 @@ Now let's switch to working with code. Let's clone a Gremlin API app from GitHub
74
66
75
67
This step is optional. If you're interested in learning how the 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-information).
76
68
77
-
The following snippets are all taken from the C:\git-samples\azure-cosmos-db-graph-java-getting-started\src\GetStarted\Program.java file.
69
+
The following snippets are all taken from the *C:\git-samples\azure-cosmos-db-graph-java-getting-started\src\GetStarted\Program.java* file.
70
+
71
+
This Java console app uses a [Gremlin API](graph-introduction.md) database with the OSS [Apache TinkerPop](https://tinkerpop.apache.org/) driver.
78
72
79
-
* The Gremlin `Client` is initialized from the configuration in the C:\git-samples\azure-cosmos-db-graph-java-getting-started\src\remote.yaml file.
73
+
- The Gremlin `Client` is initialized from the configuration in the *C:\git-samples\azure-cosmos-db-graph-java-getting-started\src\remote.yaml* file.
* Series of Gremlin steps are executed using the `client.submit` method.
81
+
- Series of Gremlin steps are executed using the `client.submit` method.
88
82
89
83
```java
90
84
ResultSet results = client.submit(gremlin);
@@ -101,14 +95,14 @@ The following snippets are all taken from the C:\git-samples\azure-cosmos-db-gra
101
95
102
96
Now go back to the Azure portal to get your connection information and copy it into the app. These settings enable your app to communicate with your hosted database.
103
97
104
-
1. In the [Azure portal](https://portal.azure.com/), select **Keys**.
98
+
1. In your Azure Cosmos DB account in the [Azure portal](https://portal.azure.com/), select **Keys**.
105
99
106
100
Copy the first portion of the URI value.
107
101
108
102

109
-
2. Open the src/remote.yaml file and paste the unique ID value over `$name$` in `hosts: [$name$.graphs.azure.com]`.
103
+
2. Open the *src/remote.yaml* file and paste the unique ID value over `$name$` in `hosts: [$name$.graphs.azure.com]`.
110
104
111
-
Line 1 of remote.yaml should now look similar to
105
+
Line 1 of *remote.yaml* should now look similar to
112
106
113
107
`hosts: [test-graph.graphs.azure.com]`
114
108
@@ -120,11 +114,11 @@ Now go back to the Azure portal to get your connection information and copy it i
120
114
121
115
4. In the Azure portal, use the copy button to copy the PRIMARY KEY and paste it over `$masterKey$` in `password: $masterKey$`.
122
116
123
-
Line 4 of remote.yaml should now look similar to
117
+
Line 4 of *remote.yaml* should now look similar to
124
118
125
119
`password: 2Ggkr662ifxz2Mg==`
126
120
127
-
5. Change line 3 of remote.yaml from
121
+
5. Change line 3 of *remote.yaml* from
128
122
129
123
`username: /dbs/$database$/colls/$collection$`
130
124
@@ -134,7 +128,7 @@ Now go back to the Azure portal to get your connection information and copy it i
134
128
135
129
If you used a unique name for your sample database or graph, update the values as appropriate.
136
130
137
-
6. Save the remote.yaml file.
131
+
6. Save the *remote.yaml* file.
138
132
139
133
## Run the console app
140
134
@@ -167,7 +161,7 @@ Now go back to the Azure portal to get your connection information and copy it i
167
161
168
162
You can now go back to Data Explorer and see the vertices added to the graph, and add additional data points.
169
163
170
-
1. Select **Data Explorer**, expand **sample-graph**, select **Graph**, and then select **Apply Filter**.
164
+
1. In your Azure Cosmos DB account in the Azure portal, select **Data Explorer**, expand **sample-graph**, select **Graph**, and then select **Apply Filter**.
171
165
172
166

173
167
@@ -208,7 +202,7 @@ You can now go back to Data Explorer and see the vertices added to the graph, an
208
202
209
203
10. Select **OK**.
210
204
211
-
11. ClSelectck the **Apply Filter** button with the default `g.V()` filter to display all the values in the graph. All of the users now show in the **Results** list.
205
+
11. Select the **Apply Filter** button with the default `g.V()` filter to display all the values in the graph. All of the users now show in the **Results** list.
212
206
213
207
As you add more data, you can use filters to limit your results. By default, Data Explorer uses `g.V()` to retrieve all vertices in a graph. You can change it to a different [graph query](tutorial-query-graph.md), such as `g.V().count()`, to return a count of all the vertices in the graph in JSON format. If you changed the filter, change the filter back to `g.V()` and select**Apply Filter** to display all the results again.
214
208
@@ -224,7 +218,7 @@ You can now go back to Data Explorer and see the vertices added to the graph, an
224
218
225
219

226
220
227
-
That completes the resource creation part of this tutorial. You can continue to add vertexes to your graph, modify the existing vertexes, or change the queries. Now let's review the metrics Azure Cosmos DB provides, and then clean up the resources.
221
+
That completes the resource creation part of this tutorial. You can continue to add vertexes to your graph, modify the existing vertexes, or change the queries. Now let's review the metrics Azure Cosmos DB provides, and then clean up the resources.
228
222
229
223
## Review SLAs in the Azure portal
230
224
@@ -236,7 +230,7 @@ You can now go back to Data Explorer and see the vertices added to the graph, an
236
230
237
231
## Next steps
238
232
239
-
In this quickstart, you've learned how to create an Azure Cosmos DB account, create a graph using the Data Explorer, and run an app. You can now build more complex queries and implement powerful graph traversal logic using Gremlin.
233
+
In this quickstart, you learned how to create an Azure Cosmos DB account, create a graph using the Data Explorer, and run a Java app that adds data to the graph. You can now build more complex queries and implement powerful graph traversal logic using Gremlin.
Copy file name to clipboardExpand all lines: articles/cosmos-db/create-graph-nodejs.md
+15-18Lines changed: 15 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,17 +21,12 @@ ms.author: lbosq
21
21
> *[PHP](create-graph-php.md)
22
22
>
23
23
24
-
Azure Cosmos DB is the globally distributed multimodel database service from Microsoft. You can quickly create and query document, key/value, and graph databases, all of which benefit from the global distribution and horizontal scale capabilities at the core of Azure Cosmos DB.
25
-
26
-
This quickstart demonstrates how to create an Azure Cosmos DB [Gremlin API](graph-introduction.md) account, database, and graph using the Azure portal. You then build and run a console app by using the open-source [Gremlin Node.js](https://www.npmjs.com/package/gremlin) driver.
24
+
In this quickstart, you create and manage an Azure Cosmos DB Gremlin (graph) API account from the Azure portal, and add data 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.
27
25
28
26
## Prerequisites
29
-
30
-
Before you can run this sample, you must have the following prerequisites:
31
-
*[Node.js](https://nodejs.org/en/) version v0.10.29 or later
- 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).
28
+
-[Node.js 0.10.29+](https://nodejs.org/).
29
+
-[Git](https://git-scm.com/downloads).
35
30
36
31
## Create a database account
37
32
@@ -69,7 +64,9 @@ Now let's clone a Gremlin API app from GitHub, set the connection string, and ru
69
64
70
65
This step is optional. If you're interested in learning how the 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).
71
66
72
-
The following snippets are all taken from the app.js file.
67
+
The following snippets are all taken from the *app.js* file.
68
+
69
+
This console app uses the open-source [Gremlin Node.js](https://www.npmjs.com/package/gremlin) driver.
73
70
74
71
* The Gremlin client is created.
75
72
@@ -92,7 +89,7 @@ The following snippets are all taken from the app.js file.
92
89
93
90
```
94
91
95
-
The configurations are all in `config.js`, which we edit in the [following section](#update-your-connection-string).
92
+
The configurations are all in *config.js*, which we edit in the [following section](#update-your-connection-string).
96
93
97
94
* A series of functions are defined to execute different Gremlin operations. This is one of them:
98
95
@@ -146,23 +143,23 @@ The following snippets are all taken from the app.js file.
146
143
147
144
## Update your connection string
148
145
149
-
1. Open the config.js file.
146
+
1. Open the *config.js* file.
150
147
151
-
2. In config.js, fill in the `config.endpoint` key with the **Gremlin URI** value from the **Overview** page of the Azure portal.
148
+
2. In *config.js*, fill in the `config.endpoint` key with the **Gremlin Endpoint** value from the **Overview** page of your Cosmos DB account in the Azure portal.

152
+

156
153
157
-
3. In config.js, fill in the config.primaryKey value with the **Primary Key** value from the **Keys** page of the Azure portal.
154
+
3. In *config.js*, fill in the config.primaryKey value with the **Primary Key** value from the **Keys** page of your Cosmos DB account in the Azure portal.
4. Enter the database name, and graph (container) name for the value of config.database and config.collection.
164
161
165
-
Here's an example of what your completed config.js file should look like:
162
+
Here's an example of what your completed *config.js* file should look like:
166
163
167
164
```javascript
168
165
var config = {}
@@ -178,7 +175,7 @@ module.exports = config;
178
175
179
176
## Run the console app
180
177
181
-
1. Open a terminal window and change (via `cd` command) to the installation directory forthe package.json file that's includedin the project.
178
+
1. Open a terminal window and change (via `cd` command) to the installation directory forthe *package.json* file that's includedin the project.
182
179
183
180
2. Run `npm install` to install the required npm modules, including `gremlin`.
184
181
@@ -204,7 +201,7 @@ Try completing `g.V()` with `.has('firstName', 'Thomas')` to test the filter. No
204
201
205
202
## Next steps
206
203
207
-
In this article, you learned how to create an Azure Cosmos DB account, create a graph by using Data Explorer, and run an app. You can now build more complex queries and implement powerful graph traversal logic by using Gremlin.
204
+
In this article, you learned how to create an Azure Cosmos DB account, create a graph by using Data Explorer, and run a Node.js app to add data to the graph. You can now build more complex queries and implement powerful graph traversal logic by using Gremlin.
208
205
209
206
> [!div class="nextstepaction"]
210
207
> [Query by using Gremlin](tutorial-query-graph.md)
0 commit comments