Azure CosmosDB Table API - table.CreateIfNotExists() call hanging

Viewed 610

I've downloaded and ran the Quickstart application successfully but I can't get things to work from my web application. (when I call table.CreateIfNotExists(), execution just hangs indefinitely). It's clearly a conflict with another library but I haven't been able to pinpoint the exact issue.

I've tried everything i can think of (including removing and re-installing the WindowsAzure.Storage-PremiumTable 0.1.0-preview library and installing) but to no avail. The suspect the conflict is related to the Microsoft.AspNet.OData library (for oData v4), which I also need in my project. It has some dependencies to Microsoft.Extensions.. (>= 1.0.0 && < 2.0.0) which I've read from another user online was the cause of a similar issue which was fixed by upgrading to v2.0). In any case, I can't upgrade these because of Microsoft.AspNet.OData's dependency.

Below is the output window when successful (from quickstart app or another application that has minimal additional libraries):

DocDBTrace Information: 0 : Set WriteEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/ ReadEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Information: 0 : TimerPool Created with minSupportedTimerDelayInSeconds = 60
DocDBTrace Information: 0 : RntbdConnectionDispenser: requestTimeoutInSeconds: 60, openTimeoutInSeconds: 0, timerValueInSeconds: 60
DocDBTrace Error: 0 : DocumentClientException with status code: NotFound, message: Message: {"Errors":["Resource Not Found"]}
ActivityId: eed42269-739c-43cd-a964-e8addb2c0a29, Request URI: /apps/cbec8afc-ed09-4565-be2a-46723dded3c3/services/ad31a99f-f874-4862-9dd4-60af25fbc416/partitions/4fd158a1-3b2f-4d61-8ee1-9ee8767d13c1/replicas/131504437541513138s, and response headers: {
"Transfer-Encoding": "chunked",
"x-ms-last-state-change-utc": "Sun, 24 Sep 2017 19:02:14.321 GMT",
"x-ms-schemaversion": "1.3",
"x-ms-xp-role": "2",
"x-ms-global-Committed-lsn": "39",
"x-ms-number-of-read-regions": "0",
"x-ms-request-charge": "2",
"x-ms-serviceversion": "version=1.17.52.1",
"x-ms-activity-id": "eed42269-739c-43cd-a964-e8addb2c0a29",
"x-ms-session-token": "0:40",
"Strict-Transport-Security": "max-age=31536000",
"x-ms-gatewayversion": "version=1.17.52.1",
"Date": "Tue, 26 Sep 2017 19:44:45 GMT",
"Server": "Microsoft-HTTPAPI/2.0",
}

And here's the output window from my project when I call table.CreateIfNotExists(), i.e the issue:

DocDBTrace Information: 0 : Set WriteEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/ ReadEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Information: 0 : TimerPool Created with minSupportedTimerDelayInSeconds = 60
DocDBTrace Information: 0 : RntbdConnectionDispenser: requestTimeoutInSeconds: 60, openTimeoutInSeconds: 0, timerValueInSeconds: 60
DocDBTrace Warning: 0 : Endpoint not reachable. Refresh cache and retry
DocDBTrace Information: 0 : MarkEndpointUnavailable() read EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/ write EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Information: 0 : RefreshLocationAsync() refreshing locations
DocDBTrace Information: 0 : Set WriteEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/ ReadEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Warning: 0 : Endpoint not reachable. Refresh cache and retry
DocDBTrace Information: 0 : MarkEndpointUnavailable() read EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/ write EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Information: 0 : RefreshLocationAsync() refreshing locations
DocDBTrace Information: 0 : Set WriteEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/ ReadEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Warning: 0 : Endpoint not reachable. Refresh cache and retry
DocDBTrace Information: 0 : MarkEndpointUnavailable() read EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/ write EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Information: 0 : RefreshLocationAsync() refreshing locations
DocDBTrace Information: 0 : Set WriteEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/ ReadEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Warning: 0 : Endpoint not reachable. Refresh cache and retry
DocDBTrace Information: 0 : MarkEndpointUnavailable() read EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/ write EP = https://trfk-cosmos1-neu-northeurope.documents.azure.com/
DocDBTrace Information: 0 : RefreshLocationAsync() refreshing locations
DocDBTrace Information: 0 : Set WriteEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/ ReadEndpoint https://trfk-cosmos1-neu-northeurope.documents.azure.com/
2 Answers

Converting to async should fix that issue.

await table.CreateIfNotExistsAsync();

Ensure to use the most recent nuget packages and double check you have the correct connection string format. They changed this at some point, which gave me issues. You can check this in the Azure portal in the Cosmos DB account under "Connection Strings" .. "PRIMARY CONNECTION STRING" (or SECONDARY)

Related