Azure CosmosDB(Gremlin API),如何使用Gremlin.Net进行连接

时间:2018-01-09 13:33:10

标签: c# azure-cosmosdb gremlin

我正在尝试使用Gremlin.Net NuGet包连接到Azure CosmosDB(Gremlin API),使用包https://www.nuget.org/packages/Gremlin.Net

GremlinClient

在Azure门户上,我可以获取密钥(用于CosmosDB客户端NuGet包:Microsoft.Azure.DocumentDB和Microsoft.Azure.Graphs)

enter image description here

如何获取ssl,port,用户名密码凭据以连接到Azure CosmosDB(Gremlin API)以在Gremlin.Net NuGet包上使用?< / p>

3 个答案:

答案 0 :(得分:5)

由于您要连接到gremlin服务器的公共端口,因此您可以使用它们在文档中显示的相同信息进行连接 通过gremlin控制台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 }}

我能够使用以下行连接:

        var gremlinServer = new GremlinServer("XXX.graphs.azure.com", 443, true, "/dbs/your_database_account/colls/your_collection",
            "password");

此外,如果您使用的是.NET和Cosmos,则会提供Microsoft提供的名为Microsoft.Azure.Graphs的NuGet软件包,该软件包目前处于预览状态。

答案 1 :(得分:1)

目前,您可以在理论上使用.net驱动程序连接到Cosmos,但即使可以,您也无法遍历图表,因为Cosmos目前不支持字节码流。

他们试图在今年上半年推出它,但github issue is kinda quiet at the time of my writing this.

答案 2 :(得分:1)

Azure Cosmos DB团队宣布他们不再投资任何Microsoft.Azure.Graphs版本的进一步版本。没有人进一步进入 - 预览阶段。 Microsoft.Azure.Graphs 0.3.1中有关于浮点十进制转换的预测也报告了一些错误 - 例如正如您在纬度和经度转换中所发现的那样。负( - )连字符在转换中丢失... Azure Cosmos DB团队现在强烈建议从现在开始使用Gremlin.Net。如前所述,Azure Cosmos DB中使用的Gremlin.Net选项在此阶段不支持字节码流,所以我想我们应该耐心并给跑步者一个机会。与此同时,你仍然可以看看如下有关如何将Gremlin.Net与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