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
@@ -26,7 +26,7 @@ In this quickstart, you create and manage an Azure Cosmos DB for Gremlin (graph)
26
26
27
27
## Prerequisites
28
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.
29
-
-[Python 3.6+](https://www.python.org/downloads/) including [pip](https://pip.pypa.io/en/stable/installing/) package installer.
29
+
-[Python 3.7+](https://github.com/Azure/azure-sdk-for-python/wiki/Azure-SDKs-Python-version-support-policy) including [pip](https://pip.pypa.io/en/stable/installing/) package installer.
30
30
-[Python Driver for Gremlin](https://github.com/apache/tinkerpop/tree/master/gremlin-python).
31
31
32
32
You can also install the Python driver for Gremlin by using the `pip` command line:
@@ -55,31 +55,25 @@ Before you can create a graph database, you need to create a Gremlin (Graph) dat
55
55
56
56
## Clone the sample application
57
57
58
-
Now let's switch to working with code. Let's clone a Gremlin API app from GitHub, set the connection string, and run it. You'll see how easy it is to work with data programmatically.
58
+
Now let's switch to working with code. Let's clone a Gremlin API app from GitHub, set the connection string, and run it. You'll see how easy it's to work with data programmatically.
59
59
60
-
1.Open a command prompt, create a new folder named git-samples, then close the command prompt.
60
+
1.Run the following command to clone the sample repository to your local machine. This command creates a copy of the sample app on your computer. Start at in the root of the folder where you typically store GitHub repositories.
61
61
62
62
```bash
63
-
mkdir "./git-samples"
64
-
```
65
-
66
-
2. Open a git terminal window, such as git bash, and use the `cd`command to change to a folder to install the sample app.
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. The snippets are all taken from the *connect.py* file in the *C:\git-samples\azure-cosmos-db-graph-python-getting-started\\* folder. Otherwise, you can skip ahead to [Update your connection string](#update-your-connection-information).
74
+
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. The snippets are all taken from the *connect.py* file in the repo [git-samples\azure-cosmos-db-graph-python-getting-started](https://github.com/Azure-Samples/azure-cosmos-db-graph-python-getting-started). Otherwise, you can skip ahead to [Update your connection string](#update-your-connection-information).
81
75
82
-
* The Gremlin `client` is initialized in line 155 in *connect.py*. Make sure to replace `<YOUR_DATABASE>` and `<YOUR_CONTAINER_OR_GRAPH>` with the values of your account's database name and graph name:
76
+
* The Gremlin `client` is initialized in *connect.py* with `client.Client()`. Make sure to replace `<YOUR_DATABASE>` and `<YOUR_CONTAINER_OR_GRAPH>` with the values of your account's database name and graph name:
83
77
84
78
```python
85
79
...
@@ -89,7 +83,7 @@ This step is optional. If you're interested in learning how the database resourc
89
83
...
90
84
```
91
85
92
-
* A series of Gremlin steps are declared at the beginning of the *connect.py* file. They are then executed using the `client.submitAsync()` method:
86
+
* A series of Gremlin steps (queries) are declared at the beginning of the *connect.py* file. They're then executed using the `client.submitAsync()` method. For example, to run the cleanup graph step, you'd use the following code:
93
87
94
88
```python
95
89
client.submitAsync(_gremlin_cleanup_graph)
@@ -101,11 +95,11 @@ Now go back to the Azure portal to get your connection information and copy it i
101
95
102
96
1. In your Azure Cosmos DB account in the [Azure portal](https://portal.azure.com/), select**Keys**.
103
97
104
-
Copy the first portion of the URI value.
98
+
Copy the first portion of the **URI** value.
105
99
106
100
:::image type="content" source="./media/quickstart-python/keys.png" alt-text="View and copy an access key in the Azure portal, Keys page":::
107
101
108
-
2. Open the *connect.py* file and in line 155 paste the URI value over `<YOUR_ENDPOINT>`in here:
102
+
2. Open the *connect.py* file, find the `client.Client()` definition, and paste the URI value over `<YOUR_ENDPOINT>`in here:
@@ -133,9 +127,9 @@ Now go back to the Azure portal to get your connection information and copy it i
133
127
password="<YOUR_PASSWORD>")
134
128
```
135
129
136
-
4. On the **Keys** page, use the copy button to copy the PRIMARY KEY and paste it over `<YOUR_PASSWORD>`in the `password=<YOUR_PASSWORD>` parameter.
130
+
4. On the **Keys** page, use the copy button to copy the **PRIMARY KEY** and paste it over `<YOUR_PASSWORD>`in the `password=<YOUR_PASSWORD>` parameter.
137
131
138
-
The entire `client` object definition should now look like this code:
132
+
The `client` object definition should now look similar to the following:
@@ -146,19 +140,19 @@ Now go back to the Azure portal to get your connection information and copy it i
146
140
147
141
## Run the console app
148
142
149
-
1. In the git terminal window, `cd`to the azure-cosmos-db-graph-python-getting-started folder.
143
+
1. Start in a terminal window inthe root of the folder where you cloned the sample app. If you are using Visual Studio Code, you can open a terminal window by selecting **Terminal**>**New Terminal**. Typically, you'll create a virtual environment to run the code. For more information, see [Python virtual environments](https://docs.python.org/3/tutorial/venv.html).
2. In the git terminal window, use the following command to install the required Python packages.
149
+
1. Install the required Python packages.
156
150
157
151
```
158
152
pip install -r requirements.txt
159
153
```
160
154
161
-
3. In the git terminal window, use the following command to start the Python application.
155
+
1. Start the Python application.
162
156
163
157
```
164
158
python connect.py
@@ -173,11 +167,11 @@ Now go back to the Azure portal to get your connection information and copy it i
173
167
<a id="add-sample-data"></a>
174
168
## Review and add sample data
175
169
176
-
After the vertices and edges are inserted, you can now go back to Data Explorer and see the vertices added to the graph, and add additional data points.
170
+
After the vertices and edges are inserted, you can now go back to Data Explorer and see the vertices added to the graph, and add more data points.
177
171
178
-
1. In your Azure Cosmos DB account in the Azure portal, select**Data Explorer**, expand **sample-graph**, select**Graph**, and thenselect**Apply Filter**.
172
+
1. In your Azure Cosmos DB account in the Azure portal, select **Data Explorer**, expand **sample-database**, expand **sample-graph**, select **Graph**, and then select **Execute Gremlin Query**.
179
173
180
-
:::image type="content" source="./media/quickstart-python/azure-cosmosdb-data-explorer-expanded.png" alt-text="Screenshot shows Graph selected from the A P I with the option to Apply Filter.":::
174
+
:::image type="content" source="./media/quickstart-python/azure-cosmosdb-data-explorer-expanded.png" alt-text="Screenshot shows Graph selected from the A P I with the option to Execute Gremlin Query.":::
181
175
182
176
2. In the **Results** list, notice three new users are added to the graph. You can move the vertices around by dragging and dropping, zoom in and out by scrolling the wheel of your mouse, and expand the size of the graph with the double-arrow.
183
177
@@ -189,12 +183,12 @@ After the vertices and edges are inserted, you can now go back to Data Explorer
189
183
190
184
4. Enter a label of *person*.
191
185
192
-
5. Select **Add property** to add each of the following properties. Notice that you can create unique properties for each person in your graph. Only the id key is required.
186
+
5. Select **Add property** to add each of the following properties. Notice that you can create unique properties foreach personin your graph. Only the ID key is required.
193
187
194
188
key|value|Notes
195
189
----|----|----
196
190
pk|/pk|
197
-
id|ashley|The unique identifier for the vertex. If you don't specify an id, one is generated for you.
191
+
id|ashley|The unique identifier for the vertex. If you don't specify an ID, one is generated for you.
198
192
gender|female|
199
193
tech | java |
200
194
@@ -203,7 +197,7 @@ After the vertices and edges are inserted, you can now go back to Data Explorer
203
197
204
198
6. Select **OK**. You may need to expand your screen to see **OK** on the bottom of the screen.
205
199
206
-
7. Select **New Vertex** again and add an additional new user.
200
+
7. Select **New Vertex** again and add another new user.
207
201
208
202
8. Enter a label of *person*.
209
203
@@ -212,17 +206,17 @@ After the vertices and edges are inserted, you can now go back to Data Explorer
212
206
key|value|Notes
213
207
----|----|----
214
208
pk|/pk|
215
-
id|rakesh|The unique identifier for the vertex. If you don't specify an id, one is generated for you.
209
+
id|rakesh|The unique identifier for the vertex. If you don't specify an ID, one is generated for you.
216
210
gender|male|
217
211
school|MIT|
218
212
219
213
10. Select **OK**.
220
214
221
-
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.
215
+
11. Select the **Execute Gremlin Query** 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.
222
216
223
-
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.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.
217
+
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.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**Execute Gremlin Query** to display all the results again.
224
218
225
-
12. Now we can connect rakesh and ashley. Ensure **ashley** is selected in the **Results** list, then select the edit button next to **Targets** on lower right side. You may need to widen your window to see the **Properties** area.
219
+
12. Now we can connect **rakesh** and **ashley**. Ensure **ashley** is selected in the **Results** list, thenselectthe edit button next to **Targets** on lower right side. You may need to widen your window to see the **Properties** area.
226
220
227
221
:::image type="content" source="./media/quickstart-python/azure-cosmosdb-data-explorer-edit-target.png" alt-text="Change the target of a vertex in a graph":::
Copy file name to clipboardExpand all lines: articles/cosmos-db/includes/cosmos-db-create-graph.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,8 @@ You can now use the Data Explorer tool in the Azure portal to create a graph dat
23
23
24
24
Setting|Suggested value|Description
25
25
---|---|---
26
-
Database ID|sample-database|Enter *sample-database* as the name for the new database. Database names must be between 1 and 255 characters, and cannot contain `/ \ # ?` or a trailing space.
27
-
Throughput|400 RUs|Change the throughput to 400 request units per second (RU/s). If you want to reduce latency, you can scale up the throughput later.
26
+
Database ID|sample-database|Enter *sample-database* as the name for the new database. Database names must be between 1 and 255 characters, and can't contain `/ \ # ?` or a trailing space.
27
+
Throughput|400 RUs|Change the throughput to 400 request units per second (RU/s). If you want to reduce latency, you can scale up the throughput later. If you chose [serverless](/azure/cosmos-db/serverless) capacity mode, then throughput isn't required.
28
28
Graph ID|sample-graph|Enter *sample-graph* as the name for your new collection. Graph names have the same character requirements as database IDs.
29
29
Partition Key| /pk |All Azure Cosmos DB accounts need a partition key to horizontally scale. Learn how to select an appropriate partition key in the [Graph Data Partitioning article](..\gremlin\partitioning.md).
0 commit comments