Skip to content

Commit 7b5c9da

Browse files
author
David Sanchez (MSFT)
authored
Merge pull request microsoft#24 from fpelaez/AZFunction/removegremlin
remove gremlin piece of the AZ function code
2 parents 293e920 + f6b1595 commit 7b5c9da

File tree

2 files changed

+1
-62
lines changed

2 files changed

+1
-62
lines changed

Source/SmartHotel360.WebsiteFunction/PetChecker.cs

-59
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Gremlin.Net.Driver;
2-
using Gremlin.Net.Structure.IO.GraphSON;
31
using Microsoft.AspNetCore.Mvc;
42
using Microsoft.Azure.Documents;
53
using Microsoft.Azure.Documents.Client;
@@ -55,8 +53,6 @@ public static async Task RunPetChecker(
5553
doc.Message = message;
5654
log.Info($"--- Updating CosmosDb document to have historical data");
5755
await UpsertDocument(doc, log);
58-
log.Info($"--- Updating Graph");
59-
await InsertInGraph(tags, doc, log);
6056
log.Info("--- Sending SignalR response.");
6157
sendingResponse = true;
6258
await SendSignalRResponse(sender, allowed, message);
@@ -99,61 +95,6 @@ private static Task SendSignalRResponse(IAsyncCollector<SignalRMessage> sender,
9995

10096
}
10197

102-
private static async Task InsertInGraph(IEnumerable<string> tags, dynamic doc, TraceWriter log)
103-
{
104-
var hostname = await GetSecret("gremlin_endpoint");
105-
var port = await GetSecret("gremlin_port");
106-
var database = "pets";
107-
var collection = "checks";
108-
var authKey = Environment.GetEnvironmentVariable("gremlin_key");
109-
var portToUse = 443;
110-
portToUse = int.TryParse(port, out portToUse) ? portToUse : 443;
111-
112-
var gremlinServer = new GremlinServer(hostname, portToUse, enableSsl: true,
113-
username: "/dbs/" + database + "/colls/" + collection,
114-
password: authKey);
115-
var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType);
116-
foreach (var tag in tags)
117-
{
118-
log.Info("--- --- Checking vertex for tag " + tag);
119-
await TryAddTag(gremlinClient, tag, log);
120-
}
121-
122-
var queries = AddPetToGraphQueries(doc, tags);
123-
log.Info("--- --- Adding vertex for pet checkin ");
124-
foreach (string query in queries)
125-
{
126-
await gremlinClient.SubmitAsync<dynamic>(query);
127-
}
128-
}
129-
130-
private static async Task TryAddTag(GremlinClient gremlinClient, string tag, TraceWriter log)
131-
{
132-
var query = $"g.V('{tag}')";
133-
var response = await gremlinClient.SubmitAsync<dynamic>(query);
134-
135-
if (!response.Any())
136-
{
137-
log.Info("--- --- Adding vertex for tag " + tag);
138-
await gremlinClient.SubmitAsync<dynamic>(AddTagToGraphQuery(tag));
139-
}
140-
}
141-
142-
private static IEnumerable<string> AddPetToGraphQueries(dynamic doc, IEnumerable<string> tags)
143-
{
144-
var id = doc.id.ToString();
145-
146-
var msg = (doc.Message?.ToString() ?? "").Replace("'", "\'");
147-
148-
yield return $"g.addV('checkin').property('id','{id}').property('description','{msg}')";
149-
foreach (var tag in tags)
150-
{
151-
yield return $"g.V('{id}').addE('seems').to(g.V('{tag}'))";
152-
}
153-
}
154-
155-
private static string AddTagToGraphQuery(string tag) => $"g.addV('tag').property('id', '{tag}').property('value', '{tag}')";
156-
15798
private static async Task UpsertDocument(dynamic doc, TraceWriter log)
15899
{
159100
var endpoint = await GetSecret("cosmos_uri");

Source/SmartHotel360.WebsiteFunction/SmartHotel360.WebsiteFunction.csproj

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
<ItemGroup>
77
<None Remove="lib\Microsoft.ProjectOxford.Vision.dll" />
88
</ItemGroup>
9-
<ItemGroup>
10-
<PackageReference Include="Gremlin.Net" Version="3.3.4" />
11-
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.0" />
9+
<ItemGroup>
1210
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.1.0-preview" />
1311
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.23" />
1412
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.1" />

0 commit comments

Comments
 (0)