Reputation: 44439
Using the Azure Cosmos DB Data Explorer shows me no values, even though I know there's data in it. When using my web app, I can see it inserts data. I can also verify this by querying db.files.stats().count
from a local GUI. However at any point in the UI where I try to read from the DB, it breaks -- seemingly the same issue as what I see in the GUIs I've tried to use.
Looking at the network tab in Chrome, I can see a failed request being sent to the https://portal-prod-northeurope-mongo.portal-prod-northeurope.p.azurewebsites.net
endpoint whenever I try to refresh the result set.
The response it comes back with is
Command find failed: Unknown server error occurred when processing this request..
I get the same error when I query the db with a local GUI so I assume it's not directly related to the Azure Portal. I have tried to delete and recreate the collections but to no avail. When I run all this locally on the Cosmos DB emulator, it works just fine.
Collections are defined as such:
az cosmosdb collection create --resource-group $resourceGroup `
--name $dbService `
--collection-name 'files' `
--db-name $db `
--partition-key-path '/p'
az cosmosdb collection create --resource-group $resourceGroup `
--name $dbService `
--collection-name 'users' `
--db-name $db
az cosmosdb collection create --resource-group $resourceGroup `
--name $dbService `
--collection-name 'projects' `
--db-name $db `
--partition-key-path '/cb'
and an example object is the following:
internal class File
{
[JsonProperty(PropertyName = "id")]
public Guid Id { get; set; }
[JsonProperty(PropertyName = "of")]
public string OriginalFilename { get; set; }
[JsonProperty(PropertyName = "if")]
public string InternalFilename { get; set; }
[JsonProperty(PropertyName = "ua")]
public DateTime UploadedAt { get; set; }
[JsonProperty(PropertyName = "p")]
public Guid ProjectId { get; set; }
[JsonProperty(PropertyName = "su")]
public string StorageUri { get; set; }
[JsonProperty(PropertyName = "t")]
public byte Type { get; set; }
public override string ToString() => JsonConvert.SerializeObject(this);
}
Upvotes: 1
Views: 3076
Reputation: 15583
As per the comments, the reason you are facing this issue is because you are using Cosmos DB SDK on a Mongo API account. Both the Portal and GUI are trying to consume the data through a Mongo client, and your data is being saved through a different API.
Cosmos DB SDK uses the SQL API to save documents. Mongo API accounts are meant to be used and consumed through Mongo Clients / Drivers.
If your application requires Mongo, then use Mongo Clients / Drivers to store the documents, don't use the Cosmos DB SDK.
If your application does not require Mongo (since you are using the Cosmos DB SDK it doesn't sound like it), create a Core API(SQL) account.
Upvotes: 1
Reputation: 1027
Is there a data migration involved here...how is the data being created in Cosmos DB? Can you please provide a Json document example with all the system generated properties. The Data Explorer issues tend to exist this migrated data where a predefined ID value is provided but doesn't match the format required by Cosmos DB.
Upvotes: 1