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

问题描述:

我正在尝试使用软件包 https://www.nuget.org/packages/Gremlin.Net

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

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

On Azure Portal, I can obtain the Key (used on CosmosDB client NuGet packages: Microsoft.Azure.DocumentDB and Microsoft.Azure.Graphs)

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

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?

由于您正在连接到gremlin服务器的公共端口,因此可以使用文档中显示的相同信息来进行连接 通过gremlin控制台此处

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");

如果您使用的是.NET和Cosmos,则还有一个Microsoft提供的名为Microsoft.Azure.Graphs的NuGet程序包,该程序包当前处于预览状态.

Also if you are using .NET and Cosmos there is a Microsoft provided NuGet package called Microsoft.Azure.Graphs which is currently in preview.