alexdrenea/CosmosDb.Net

What is "Account Name"?

chuckgiddens opened this issue · 12 comments

I am simply trying to connect to my CosmosDB - Gremlin service. I put in the server URL but it will not connect. Where is this "Account Name" property displayed in Azure Portal?

Thanks

I put in the name of the CosmosDB instance and now I get this:

Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: aaf63c2b-6936-479f-b982-2aca4878c750; Reason: ({
"code": "NotFound",
"message": "Message: {"Errors":["Resource Not Found"]}\r\nActivityId: aaf63c2b-6936-479f-b982-2aca4878c750, Request URI: /apps/d27ef9bf-18ce-4431-b8de-709648aab568/services/c02b70da-ed54-4f3c-827e-cf6c0e1eaf69/partitions/70502dc1-904f-4df4-afe0-0b5611870bfd/replicas/132409629003468060s, RequestStats: \r\nRequestStartTime: 2020-08-04T13:00:37.6012387Z, RequestEndTime: 2020-08-04T13:00:37.6112301Z, Number of regions attempted:1\r\nResponseTime: 2020-08-04T13:00:37.6112301Z, StoreResult: StorePhysicalAddress: rntbd://10.0.0.24:11300/apps/d27ef9bf-18ce-4431-b8de-709648aab568/services/c02b70da-ed54-4f3c-827e-cf6c0e1eaf69/partitions/70502dc1-904f-4df4-afe0-0b5611870bfd/replicas/132409629003468060s, LSN: 16, GlobalCommittedLsn: 16, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#16, UsingLocalLSN: False, TransportException: null, ResourceType: Collection, OperationType: Read\r\nResponseTime: 2020-08-04T13:00:37.6112301Z, StoreResult: StorePhysicalAddress: rntbd://10.0.0.26:11300/apps/d27ef9bf-18ce-4431-b8de-709648aab568/services/c02b70da-ed54-4f3c-827e-cf6c0e1eaf69/partitions/70502dc1-904f-4df4-afe0-0b5611870bfd/replicas/132409893952215141s, LSN: 16, GlobalCommittedLsn: 16, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#16, UsingLocalLSN: False, TransportException: null, ResourceType: Collection, OperationType: Read\r\n, SDK: Microsoft.Azure.Documents.Common/2.11.0"
});

Hi,
The account name should be just the name of your Cosmos DB account (usually the name you provided when you created the resource). You can get it from the "keys" section, just extract it from the Account Endpoint string (after https:// and before .documents.azure.com)

image

*The reason I chose this option is because you can use this SDK with both SQL and Gremlin endpoints and it was an easier way to provide one value and build both endpoints programmatically from it, rather than ask for both values in configuration.

Yes, but now I get the error in my second message

can you share a bit more of the code itself? Is this when you initialize the library or when you call any other command?

Also, what kind of Cosmos DB flavor are you using ? The library is really only meant to be used on top of SQL or Graph accounts (have not tested on others)

`string CosmosDBCollection = Environment.GetEnvironmentVariable("CosmosDBCollection");
            string CosmosDBName = Environment.GetEnvironmentVariable("CosmosDBName");
            string CosmosDBPassword = Environment.GetEnvironmentVariable("CosmosDBPassword");
            string CosmosDBAcctName = Environment.GetEnvironmentVariable("CosmosDBAcctName");
            
            _server = await CosmosClientGraph.GetClientWithSql(CosmosDBAcctName, CosmosDBPassword, CosmosDBName, CosmosDBCollection);`

All I am doing is trying to connect to my Gremlin Database on CosmosDB

Can you validate that the database and collection actually exist in your account? If they do not, and you do not pass the CreateOptions() required to create them, then the call will fail.

Yes, I use Azure Storage Explorer to connect and query the graph database

Does the connection work using the regular CosmosDB SDK with the same parameters?
I can't think of any reason this would fail if parameters are all correct.

Thank you for the screenshot. Can you validate that the parameters are correct?

These are the values you should have based on the screenshot:

CosmosDBAcctName  = "comegowithme";
CosmosDBPassword  = <your account key>;
CosmosDBName = "graphdb";
CosmosDBCollection  = "ComeGoWithMeGraph";

yes. That is exactly what I have in the settings. On a side note, I can connect with Gremlin.Net just fine when I specify the server url.

That's very strange! I can't explain why that wouldn't work. If you want you could try the sample code in this repo to see if you can catch the exception locally to further debug. Alternatively, depending on the nature and sensitivity of your database, if you can provide me with the secondary key I can attempt to replicate the issue locally.

No, don't worry about it. I am going back to MSSQL. This is too complicated. Thanks for your help.