I am looking to quickly insert multiple vertices using Azure Cosmos DB Graph-API. Most of the current Microsoft samples create the vertices one by one and execute a Gremlin query for each, like so:
IDocumentQuery<dynamic> query = client.CreateGremlinQuery<dynamic>(graph, "g.addV('person').property('id', 'thomas').property('name', 'Thomas').property('age', 44)");
while (query.HasMoreResults)
{
foreach (dynamic result in await query.ExecuteNextAsync()) {
Console.WriteLine($"\t {JsonConvert.SerializeObject(result)}");
}
Console.WriteLine();
}
query = client.CreateGremlinQuery<dynamic>(graph, "g.addV('person').property('id', 'mary').property('name', 'Mary').property('lastName', 'Andersen').property('age', 39)");
while (query.HasMoreResults)
{
foreach (dynamic result in await query.ExecuteNextAsync()) {
Console.WriteLine($"\t {JsonConvert.SerializeObject(result)}");
}
Console.WriteLine();
}
However this is less than ideal when I want to create a couple thousand vertices and edges to initially populate the graph as this can take some time.
This is with Microsoft.Azure.Graphs library v0.2.0-preview
How can I efficiently add multiple vertices at once to Cosmos DB so I may later query using the Graph API syntax?