1
votes

I have been testing Visual Studio Code - AZURE COSMOS DB extension in combination with Graph API options and encountered Invalid credentials provided (Error 401) error. I had previously created an existing Azure Cosmos DB Graph API project on Azure Portal which had already generated URI, PRIMARY KEY as well as PRIMARY CONNECTION STRING. I had repeated the same process over and over,in many occasions, even managed to use the dtui-data migration tool to seed data and everything always went smoothly. However trying to connect to Graph API database through Visual Studio Code - AZURE COSMOS DB extension Graph Explorer user interface seemed a bit more complicated than I thought. When I wanted to provide an Attached Database Account then Visual Studio Code command prompted to

Select a Data Account API...

I selected Graph. A next Visual Studio Code command them prompts to

Enter the connection string for your database account(Press 'Enter' to confirm or 'Escape' to cancel.

I then provided the PRIMARY CONNECTION STRING of my project using similar format pattern:

AccountEndpoint=https://<my-project-endpoint>.documents.azure.com:443/;AccountKey=<my-project-primary-key==>;

I could then see the proper database and collection of the Graph API I had created earlier on Azure Portal,

enter image description here

though when clicking on collection to launch and display the graph explorer, I ended up with following Invalid credentials provided (Error 401) message:

enter image description here

Any hints on how to cope with this issue would be deeply appreciated. Thank you.

1
check your conneciton string, it must be wrongSajeetharan
Nope. Primary Connection String provided is fine otherwise I wouldn't even have been able to connect to both database and collection displayed in image I showed above. An error would have been thrown earlier in that case saying it's either wrong or not properly formatted which I doubt is the case here as I tested it running Console Application and it's fine. Problem is elsewhere in this case and wouldn't be surprised it may even be a bug with the extension. Remember a lot of VSCode extension features are still in Preview😉 Anyway I won't waste too much time on that.Mainly curiosity testing😉PeteZaria
@PeteZaria I hit the same error as you last week and I deleted the graph db and create it again and everything is fine. Could you try it?Jay Gong
Thanks for mentioning Jay. So I guess I wasn't the only one. Something must have gone wrong somewhere. As I mentioned the tool is still in Preview, so I guess we may expect a couple of unwanted strange behaviors when creating account from VS Code. So I deleted everything and started all from scratch. New database and collections created on Azure Portal appeared in the list and I was able to have access to each and every one using Graph Explorer this time. Great.PeteZaria

1 Answers

0
votes

If this graph account created before Graph GA'ed in February (https://azure.microsoft.com/en-us/blog/azure-cosmosdb-graph-api-now-generally-available/), then you need to create a new account and try again. The gremlin support in Azure is much better with GA graph accounts. You can also bring this issue up on our GitHub repro here: https://github.com/Microsoft/vscode-cosmosdb/issues.

Stephen