Search code examples
azure-cosmosdbrbacazure-cosmosdb-gremlinapi

How do i setup RBAC gremlin cosmos db DefaultAzureCredentials


I have all my Cosmos Dbs setup to authenticate using DefaultAzureCredentials, and I have the arm resource manager for my gremlin account using DefaultAzureCredentials, however I can't figure out to get it to work with the gremlin.net side.

Eg I have

var credentials = new DefaultAzureCredentials();

but how do i assign that to

var gremlinServer = new GremlinServer(hostname: _gremlinHostname,
                                                  port: _port,
                                                  enableSsl: _enableSsl,
                                                  username: $"/dbs/{options.UniverseId}/colls/{graphName}",
                                                password: !!crendentials goes here!!);

Solution

  • I believe you'll need to use the Azure CosmosDB SDK to retrieve a RBAC-based access token (the Gremlin.NET API knows nothing of Azure CosmosDB, and RBAC is a CosmosDB based concept).

    Once you have an access token retrieved, you would then pass that in as the "password" when instantiating the GremlinServer(...) object.

    See https://learn.microsoft.com/en-us/azure/cosmos-db/graph/how-to-use-resource-tokens-gremlin