Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmo DB connection #12

Open
pechaut73 opened this issue Dec 16, 2019 · 10 comments
Open

Cosmo DB connection #12

pechaut73 opened this issue Dec 16, 2019 · 10 comments

Comments

@pechaut73
Copy link

Hi,

I tried to do as you said in the command, put
TableStorageClient.Instance.EndpointStorageType = EndpointStorageType.CosmosDBTableAPI;

and

TableStorageClient.Instance.AuthenticationToken = "AccountEndpoint=https://cosmosdb-prague.documents.azure.com:443/;AccountKey=UU6OXXXXXXXXXXXXXXXXXXXXX

I launch : no error, but if I try to interrogate the DB I get an error, saying that it can not parse a webserver adress",

any idea on what I'm doing wrong ?

CHeers,
PE

@dgkanatsios
Copy link
Owner

Are you using CosmosDB with Table API? If yes, you should use the AuthenticationToken credential by setting it with your AccountKey.

https://social.msdn.microsoft.com/Forums/SECURITY/en-US/e993cf4b-41e9-4fa3-bd1a-b871f737f95b/where-is-accountkey-for-cosmosdb-in-azure-portal?forum=azurecosmosdb

@pechaut78
Copy link

Actually, the key has to be edited.
The account key should be removed and only the account name should be set, so no HTTPS decoration etc..

But even then:

if my URI is marked as: https://MYNAME.documents.azure.com:443/
I set: TableStorageClient.Instance.SetAccountName("MYNAME");

it creates a connection to: MYNAME.table.cosmosdb.azure.com/
and when hitting CreateIfNoExist, it says : can not resolve host..

is table.cosmosdb.azure.com/ correct ? The URI on the azure key page is : https://MYNAME.documents.azure.com:443/

@dgkanatsios
Copy link
Owner

is table.cosmosdb.azure.com/ correct ? The URI on the azure key page is : https://MYNAME.documents.azure.com:443/

this is the URI when Cosmos DB is used with "SQL" API. We want Cosmos DB to be used with the "Table" API. https://docs.microsoft.com/en-us/azure/cosmos-db/table-introduction

@pechaut78
Copy link

Ok, I see, but MYNAME.table.cosmosdb.azure.com/Pages() generates a host can not be resolved. If I try it in a webbrowser it says the IP adress can not be found..

@dgkanatsios
Copy link
Owner

I don't think you're supposed to call it via an unauthenticated HTTP call via a web browser. Have you tried using the CosmosDB SDK?

@pechaut78
Copy link

YEs exactly, using the app it says "can not resolve destination host" when clicking on CreateIfNoExist

In the log a connection to URL= https:/MYNAME.table.cosmosdb.azure.com/Tables()
then 0
then Cannot resolve destination host

Normally I should see an invalid request with no authorization in the browser..

@dgkanatsios
Copy link
Owner

the SDK in the Unity app works only with Cosmos DB configure with the Table API, not with the SQL API, so the myname.table.cosmosdb.azure.com url is not supposed to work.

@pechaut78
Copy link

I see, but I get:

EndpointStorageType.TableStorage :
URL= https://iot-prague.table.core.windows.net/Tables()
Cannot resolve destination host

EndpointStorageType.CosmosDBTableAPI :
https://iot-prague.table.cosmosdb.azure.com/Tables()
Cannot resolve destination host

Same result

@dgkanatsios
Copy link
Owner

Totally missed that, sorry. Did you manage to make it work?

@GnutekG
Copy link

GnutekG commented Aug 22, 2021

Hey! I have exactly the same issue. "Cannot resolve destination host". The URL that this tool generates for me looks like this:
https://ACCOUNT_NAME.table.cosmosdb.azure.com/Routes()?$select=locationName,startName,endName

Now it occured to me: there's a place for "tableName" parameter in TableStorageClient.QueryTable, what is that name if we have database A with containers B & C in it? I guess container == table, but what would happen if we had more than one database under the same account name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants