Skip to content

Commit 6c79a70

Browse files
committed
Temp hold
1 parent 13731fc commit 6c79a70

File tree

5 files changed

+200
-32
lines changed

5 files changed

+200
-32
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
author: seesharprun
3+
ms.author: sidandrews
4+
ms.service: cosmos-db
5+
ms.subservice: apache-gremlin
6+
ms.topic: include
7+
ms.date: 09/27/2023
8+
---
9+
10+
1. Open your terminal in any folder.
11+
12+
1. Use `az group delete` to delete the resource group.
13+
14+
```azurecli-interactive
15+
az group delete \
16+
--name $resourceGroupName
17+
```

articles/cosmos-db/gremlin/quickstart-console.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ In this quickstart, you use the Gremlin console to connect to a newly created Az
2828
- No Azure subscription? [Sign up for a free Azure account](https://azure.microsoft.com/free/).
2929
- Don't want an Azure subscription? You can [try Azure Cosmos DB free](../try-free.md) with no subscription required.
3030
- [Docker host](https://www.docker.com/)
31-
- Don't have Docker installed? Try this quickstart in a devcontainer. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/github/codespaces-blank?quickstart=1)
31+
- Don't have Docker installed? Try this quickstart in [GitHub Codespaces](https://codespaces.new/github/codespaces-blank?quickstart=1).
3232
- [Azure Command-Line Interface (CLI)](/cli/azure/)
3333

3434
[!INCLUDE[Cloud Shell](../../../includes/cloud-shell-try-it.md)]
@@ -146,12 +146,9 @@ Now that the console is connected to the account, use the standard Gremlin synta
146146

147147
## Clean up resources
148148

149-
When you no longer need the API for Gremlin account, delete the corresponding resource group using `az group delete`.
149+
When you no longer need the API for Gremlin account, delete the corresponding resource group.
150150

151-
```azurecli-interactive
152-
az group delete \
153-
--name $resourceGroupName
154-
```
151+
[!INCLUDE[Delete account](includes/delete-account-cli.md)]
155152

156153
## How did we solve the problem?
157154

articles/cosmos-db/gremlin/quickstart-dotnet.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In this quickstart, you use the `Gremlin.Net` library to connect to a newly crea
3030
- No Azure subscription? [Sign up for a free Azure account](https://azure.microsoft.com/free/).
3131
- Don't want an Azure subscription? You can [try Azure Cosmos DB free](../try-free.md) with no subscription required.
3232
- [.NET (LTS)](https://dotnet.microsoft.com/)
33-
- Don't have .NET installed? Try this quickstart in a devcontainer. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/github/codespaces-blank?quickstart=1)
33+
- Don't have .NET installed? Try this quickstart in [GitHub Codespaces](https://codespaces.new/github/codespaces-blank?quickstart=1).
3434
- [Azure Command-Line Interface (CLI)](/cli/azure/)
3535

3636
[!INCLUDE[Cloud Shell](../../../includes/cloud-shell-try-it.md)]
@@ -87,7 +87,7 @@ Add the `Gremlin.NET` NuGet package to the .NET project.
8787

8888
### Configure environment variables
8989

90-
To use the *NAME* and *URI* values obtained earlier in this quickstart, persist them to new environment variables on the local machine running the application.
90+
To use the *NAME* and *URI* values obtained earlier in this quickstart, persist them to new environment variables on the local machine running the application.
9191

9292
1. To set the environment variable, use your terminal to persist the values as `COSMOS_ENDPOINT` and `COSMOS_KEY` respectively.
9393

@@ -130,11 +130,11 @@ Application requests to most Azure services must be authorized. For the API for
130130

131131
1. Create a new instance of `GremlinServer` using the account's credentials.
132132
133-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="1-7" id="authenticate_client":::
133+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="authenticate_client":::
134134
135135
1. Create a new instance of `GremlinClient` using the remote server credentials and the **GraphSON 2.0** serializer.
136136
137-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="9-12" id="authenticate_client":::
137+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="connect_client":::
138138
139139
## Create vertices
140140
@@ -150,7 +150,7 @@ Now that the application is connected to the account, use the standard Gremlin s
150150
| **`price`** | `285.55` |
151151
| **`category`** | `surfboards` |
152152
153-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="1-3" id="create_vertices":::
153+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="create_vertices_1":::
154154
155155
1. Create a second **product** vertex with these properties:
156156
@@ -162,7 +162,7 @@ Now that the application is connected to the account, use the standard Gremlin s
162162
| **`price`** | `600.00` |
163163
| **`category`** | `surfboards` |
164164
165-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="9-11" id="create_vertices":::
165+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="create_vertices_2":::
166166
167167
1. Create a third **product** vertex with these properties:
168168
@@ -174,38 +174,34 @@ Now that the application is connected to the account, use the standard Gremlin s
174174
| **`price`** | `585.50` |
175175
| **`category`** | `surfboards` |
176176
177-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="5-7" id="create_vertices":::
177+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="create_vertices_3":::
178178
179179
## Create edges
180180
181181
Create edges using the Gremlin syntax to define relationships between vertices.
182182
183183
1. Create an edge from the `Montau Turtle Surfboard` product named **replaces** to the `Kiama classic surfboard` product.
184184
185-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="1-3" id="create_edges":::
185+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="create_edges_1":::
186186
187187
> [!TIP]
188188
> This edge defintion uses the `g.V(['<partition-key>', '<id>'])` syntax. Alternatively, you can use `g.V('<id>').has('category', '<partition-key>')`.
189189
190190
1. Create another **replaces** edge from the same product to the `Bondi Twin Surfboard`.
191191
192-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="5-7" id="create_edges":::
192+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="create_edges_2":::
193193
194194
## Query vertices &amp; edges
195195
196196
Use the Gremlin syntax to traverse the graph and discover relationships between vertices.
197197
198198
1. Traverse the graph and find all vertices that `Montau Turtle Surfboard` replaces.
199199
200-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="1-3" id="query_vertices_edges":::
200+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="query_vertices_edges":::
201201
202-
1. Write to the console the static string `[CREATED PRODUCT]\t68719518403`.
202+
1. Write to the console the static string `[CREATED PRODUCT]\t68719518403`. Then, iterate over each matching vertex using a `foreach` loop and write to the console a message that starts with `[REPLACES PRODUCT]` and includes the matching product `id` field as a suffix.
203203
204-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="5" id="query_vertices_edges":::
205-
206-
1. Iterate over each matching vertex using a `foreach` loop and write to the console a message that starts with `[REPLACES PRODUCT]` and includes the matching product `id` field as a suffix.
207-
208-
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" range="6-9" id="query_vertices_edges":::
204+
:::code language="csharp" source="~/cosmos-db-apache-gremlin-dotnet-samples/001-quickstart/Program.cs" id="output_vertices_edges":::
209205
210206
## Run the code
211207
@@ -231,14 +227,7 @@ Validate that your application works as expected by running the application. The
231227
232228
When you no longer need the API for Gremlin account, delete the corresponding resource group.
233229
234-
1. Open your terminal in any folder.
235-
236-
1. Use `az group delete` to delete the resource group.
237-
238-
```azurecli-interactive
239-
az group delete \
240-
--name $resourceGroupName
241-
```
230+
[!INCLUDE[Delete account](includes/delete-account-cli.md)]
242231
243232
## Next step
244233

articles/cosmos-db/gremlin/quickstart-nodejs.md

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In this quickstart, you use the `gremlin` library to connect to a newly created
3030
- No Azure subscription? [Sign up for a free Azure account](https://azure.microsoft.com/free/).
3131
- Don't want an Azure subscription? You can [try Azure Cosmos DB free](../try-free.md) with no subscription required.
3232
- [Node.js (LTS)](https://nodejs.org/)
33-
- Don't have Node.js installed? Try this quickstart in a devcontainer. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/github/codespaces-blank?quickstart=1)
33+
- Don't have Node.js installed? Try this quickstart in [GitHub Codespaces](https://codespaces.new/github/codespaces-blank?quickstart=1).codespaces.new/github/codespaces-blank?quickstart=1)
3434
- [Azure Command-Line Interface (CLI)](/cli/azure/)
3535

3636
[!INCLUDE[Cloud Shell](../../../includes/cloud-shell-try-it.md)]
@@ -45,11 +45,171 @@ The API for Gremlin account should be created prior to using the Node.js library
4545

4646
[!INCLUDE[Create account, database, and graph](includes/create-account-database-graph-cli.md)]
4747

48+
### Create a new Node.js console application
4849

50+
Create a Node.js console application in an empty folder using your preferred terminal.
4951

52+
1. Open your terminal in an empty folder.
5053

54+
1. Initialize a new module
5155

56+
```bash
57+
npm init es6 --yes
58+
```
5259

60+
1. Create the **app.js** file
61+
62+
```bash
63+
touch app.js
64+
```
65+
66+
### Install the npm package
67+
68+
Add the `gremlin` npm package to the Node.js project.
69+
70+
1. Open the **package.json** file and replace the contents with this JSON configuration.
71+
72+
```json
73+
{
74+
"main": "app.js",
75+
"type": "module",
76+
"scripts": {
77+
"start": "node app.js"
78+
},
79+
"dependencies": {
80+
"gremlin": "^3.*"
81+
}
82+
}
83+
```
84+
85+
1. Use the `npm install` command to install all packages specified in the **package.json** file.
86+
87+
```bash
88+
npm install
89+
```
90+
91+
### Configure environment variables
92+
93+
To use the *NAME* and *URI* values obtained earlier in this quickstart, persist them to new environment variables on the local machine running the application.
94+
95+
1. To set the environment variable, use your terminal to persist the values as `COSMOS_ENDPOINT` and `COSMOS_KEY` respectively.
96+
97+
```bash
98+
export COSMOS_GREMLIN_ENDPOINT="<account-name>"
99+
export COSMOS_GREMLIN_KEY="<account-key>"
100+
```
101+
102+
1. Validate that the environment variables were set correctly.
103+
104+
```bash
105+
printenv COSMOS_GREMLIN_ENDPOINT
106+
printenv COSMOS_GREMLIN_KEY
107+
```
108+
109+
## Code examples
110+
111+
- [Authenticate the client](#authenticate-the-client)
112+
- [Create vertices](#create-vertices)
113+
- [Create edges](#create-edges)
114+
- [Query vertices &amp; edges](#query-vertices--edges)
115+
116+
The code in this article connects to a database named `cosmicworks` and a graph named `products`. The code then adds vertices and edges to the graph before traversing the added items.
117+
118+
### Authenticate the client
119+
120+
Application requests to most Azure services must be authorized. For the API for Gremlin, use the *NAME* and *URI* values obtained earlier in this quickstart.
121+
122+
1. Open the **app.js** file.
123+
124+
1. Import the `gremlin` module.
125+
126+
```javascript
127+
import gremlin from 'gremlin'
128+
```
129+
130+
1. Create `accountName` and `accountKey` string variables. Store the `COSMOS_GREMLIN_ENDPOINT` and `COSMOS_GREMLIN_KEY` environment variables as the values for each respective variable.
131+
132+
```javascript
133+
134+
```
135+
136+
1. Use `PlainTextSaslAuthenticator` to create a new object for the account's credentials.
137+
138+
```javascript
139+
140+
```
141+
142+
1. Use `Client` to connect using the remote server credentials and the **GraphSON 2.0** serializer.
143+
144+
```javascript
145+
146+
```
147+
148+
1. TODO
149+
150+
```javascript
151+
152+
```
153+
154+
1. TODO
155+
156+
```javascript
157+
158+
```
159+
160+
1. TODO
161+
162+
```javascript
163+
164+
```
165+
166+
1. TODO
167+
168+
```javascript
169+
170+
```
171+
172+
1. TODO
173+
174+
```javascript
175+
176+
```
177+
178+
1. TODO
179+
180+
```javascript
181+
182+
```
183+
184+
1. TODO
185+
186+
```javascript
187+
188+
```
189+
190+
1. TODO
191+
192+
```javascript
193+
194+
```
195+
196+
1. TODO
197+
198+
```javascript
199+
200+
```
201+
202+
1. TODO
203+
204+
```javascript
205+
206+
```
207+
208+
## Clean up resources
209+
210+
When you no longer need the API for Gremlin account, delete the corresponding resource group.
211+
212+
[!INCLUDE[Delete account](includes/delete-account-cli.md)]
53213
54214
## Next step
55215

articles/cosmos-db/gremlin/quickstart-python.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In this quickstart, you use the `gremlinpython` library to connect to a newly cr
3030
- No Azure subscription? [Sign up for a free Azure account](https://azure.microsoft.com/free/).
3131
- Don't want an Azure subscription? You can [try Azure Cosmos DB free](../try-free.md) with no subscription required.
3232
- [Python (latest)](https://www.python.org/)
33-
- Don't have Python installed? Try this quickstart in a devcontainer. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/github/codespaces-blank?quickstart=1)
33+
- Don't have Python installed? Try this quickstart in [GitHub Codespaces](https://codespaces.new/github/codespaces-blank?quickstart=1).
3434
- [Azure Command-Line Interface (CLI)](/cli/azure/)
3535

3636
[!INCLUDE[Cloud Shell](../../../includes/cloud-shell-try-it.md)]
@@ -53,6 +53,11 @@ The API for Gremlin account should be created prior to using the Python library.
5353

5454

5555

56+
## Clean up resources
57+
58+
When you no longer need the API for Gremlin account, delete the corresponding resource group.
59+
60+
[!INCLUDE[Delete account](includes/delete-account-cli.md)]
5661

5762
## Next step
5863

0 commit comments

Comments
 (0)