问题
I am trying to use the Gremlin.Net NuGet package to connect to Azure CosmosDB (Gremlin API), using the Package https://www.nuget.org/packages/Gremlin.Net
On Azure Portal, I can obtain the Key (used on CosmosDB client NuGet packages: Microsoft.Azure.DocumentDB and Microsoft.Azure.Graphs)
How can I obtain the ssl, port, username and password credentials to connect to Azure CosmosDB (Gremlin API) for use on the Gremlin.Net NuGet package?
回答1:
Since you are connecting to the public port of the gremlin server you can use the same information that they show in the docs to connect via the gremlin console here.
hosts: [your_database_server.gremlin.cosmosdb.azure.com]
port: 443
username: /dbs/your_database_account/colls/your_collection
password: your_primary_key
connectionPool: {
enableSsl: true
}
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { serializeResultToString: true }}
I was able to connect using the line below:
var gremlinServer = new GremlinServer("XXX.graphs.azure.com", 443, true, "/dbs/your_database_account/colls/your_collection",
"password");
Also if you are using .NET and Cosmos there is a Microsoft provided NuGet package called Microsoft.Azure.Graphs which is currently in preview.
回答2:
Azure Cosmos DB team has announced they were no longer investing in any further release of Microsoft.Azure.Graphs versions. None ever went further the -preview stage. Some bugs were also reported in Microsoft.Azure.Graphs 0.3.1 -preview regarding float decimal conversion - e.g. as you would find in latitude&longitude conversion. Negative (-) hyphen were lost in conversion... Azure Cosmos DB team now strongly suggests using Gremlin.Net from now on. As mentioned earlier, the Gremlin.Net option used in Azure Cosmos DB doesn't support bytecode streams at this stage, so I guess we ought to be patient and give the runner a chance😉 In the meantime, you can still have a look at following links on how to use Gremlin.Net with Azure Cosmos DB Graph API
http://alexdrenea.com/2018/01/10/cosmosdb-graph-using-gremlin-net/
http://alexdrenea.com/2018/01/12/cosmosdb-with-gremlin-net-part-2/
https://github.com/Azure/azure-documentdb-dotnet/issues/439
回答3:
As it stands, you might be able to connect to Cosmos with the .net driver in theory, but even if you could, you wouldn't be able to traverse the graph because Cosmos currently doesn't support bytecode streams.
They were trying to get it out in the first part of this year, but the github issue is kinda quiet at the time of my writing this.
来源:https://stackoverflow.com/questions/48169356/azure-cosmosdb-gremlin-api-how-to-connect-using-gremlin-net