azure-cosmosdb

Querying DocumentDB using a property other than Id

点点圈 提交于 2020-01-01 12:01:05
问题 I want to query my documents in my DocumentDB database. I want to use LINQ to handle the DocumentDB query and want to query for facebookUsername field. If I use the code below for querying the standard Id field, it works fine but when I try to do it using facebookUsername field, I get a compile error that reads "'Microsoft.Azure.Documents.Document' does not contain a definition for 'facebookUsername' and no extension method 'facebookUsername' accepting a first argument of type 'Microsoft

CosmosDb with DocumentDB API through Azure API Management

烈酒焚心 提交于 2020-01-01 09:11:52
问题 I am attempting to query my new CosmosDB collection through API management. Once proved out, this will be a front-end for user access to logged data. For that reason, I have the data partitioned by subscription ID. In Azure Portal for the Logs collection of my WebApi DB I see partition key as /api_subscription_key. I have the data going in from API Mgt. -> Event Hub -> Stream Analytics -> Cosmos. Using the query explorer in Azure portal, I can try a query like: SELECT * FROM c WHERE c.api

Error when trying to update MongoDb array element

霸气de小男生 提交于 2019-12-30 10:02:09
问题 In my Azure CosmosDb MongoApi I have JSON with an embed array of documents. { "_id": ObjectId("5a95745df886842904b82f71"), "token": "value1", "channel": "value2", "urls": [ { "url": "<url1>", "interval": "<int>" }, { "url": "<url2>" "interval": "<int>" } ] } I want to update "interval" field in a specific array element. Problem is when I use solutions like this or this, I end up with an exception: MongoDB.Driver.MongoCommandException: Command findAndModify failed: Invalid BSON field name

Error when trying to update MongoDb array element

梦想的初衷 提交于 2019-12-30 10:01:54
问题 In my Azure CosmosDb MongoApi I have JSON with an embed array of documents. { "_id": ObjectId("5a95745df886842904b82f71"), "token": "value1", "channel": "value2", "urls": [ { "url": "<url1>", "interval": "<int>" }, { "url": "<url2>" "interval": "<int>" } ] } I want to update "interval" field in a specific array element. Problem is when I use solutions like this or this, I end up with an exception: MongoDB.Driver.MongoCommandException: Command findAndModify failed: Invalid BSON field name

Updating part of a Document in Azure DocumentDB

让人想犯罪 __ 提交于 2019-12-30 08:04:28
问题 Is there a way to update part of a document in a DocumentDB collection? I know that ReplaceDocumentAsync lets you update a document, but you have to replace the entire document. This sounds kind of scary. If I have an object that has other objects nested I will have to query for the parent document and then replace the entire document to update a nested part of the object. Does DocumentDB handle ReplaceDocumentAsync in a way that makes it perform better than it might seem on the surface? 回答1:

Azure DocumentDb error “Query must evaluate to IEnumerable”

早过忘川 提交于 2019-12-30 07:56:11
问题 I am having issues in trying to query my Azure DocumentDb storage account when attempting to retrieve a single record. This is my WebAPI code: // Controller... public AccountController : ApiController { // other actions... [HttpGet] [Route("Profile")] public HttpResponseMessage Profile() { var userId = User.Identity.GetUserId(); var rep = new DocumentRepository<UserDetail>(); var profile = rep.FindById(userId); if (profile == null) return Request.CreateErrorResponse(HttpStatusCode.NotFound,

How to debug Azure Cosmos DB Stored Procedures?

不想你离开。 提交于 2019-12-30 03:05:07
问题 I am working with Azure Cosmos DB, I am programming the client side in C# (web service) and I'm writing some server side Stored Procedures with java-script. How can I debug my stored procedure's code? Thanks, MAK 回答1: Azure Cosmos DB stored procedure is JS script running on the server, you can not debug it on your side. However , you can use console.log () to log some key steps in your stored procedure as below. Then use getScriptLog to get the output from stored procedure console.log()

Convert TimeScript to Date in Azure CosmosDB SQL Query

妖精的绣舞 提交于 2019-12-29 09:11:07
问题 How can I select the timescripts of my documents in Date readable format? I want to do something like this: SELECT CAST(C._ts AS DATE) FROM C Specific to Cosmos DB SQL Query only please. 回答1: Please use UDF in Cosmos DB. sample document: udf: function convertTime(unix_timestamp){ var date = new Date(unix_timestamp*1000); var year = date.getFullYear(); var month = ("0"+(date.getMonth()+1)).substr(-2); var day = ("0"+date.getDate()).substr(-2); var hour = ("0"+date.getHours()).substr(-2); var

How to Upload multiple Document (bulk) in Document DB

拜拜、爱过 提交于 2019-12-29 06:12:22
问题 I have Documents list(object) that object has multiple documents i.e. Json records are present but while I try to upload that Bunches of Document(Records) it not upload on document DB but while I upload Single Document records it upload succesfully. List<MyModelClass> listObj = new List<MyModelClass>(); Document doc = await DocumentClient.CreateDocumentAsync("dbs/" + DocumentDatabase.Id + "/colls/" + DocumentCollection.Id, listObj); above code is not working..... foreach (var item in listObj

Created Stored procedures in my CosmosDb, how can I access them through my .net wep API (which is connected to my cosmosDb) [closed]

有些话、适合烂在心里 提交于 2019-12-25 17:38:13
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last month . I've made server side stored procedure named sample ( it's the default stored procedure) how can I call it inside my .net web API ? 回答1: Reference: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos.Samples/Usage/ServerSideScripts/Program.cs Using