azure-cosmosdb

Invoking Rest API using Powershell - CosmosDb

只谈情不闲聊 提交于 2019-12-10 14:56:09
问题 I was trying to deploy cosmos database using Cosmos DB REST Api. I'm using a function to build the authorisation header and I got the script from https://gallery.technet.microsoft.com/scriptcenter/How-to-query-Azure-Cosmos-0a9aa517 link. It works perfectly fine for GET & POST however when I tried to execute a PUT command I'm always getting below error. Invoke-RestMethod : The remote server returned an error: (401) Unauthorized. Im trying to update the offer for Cosmos collection but it always

Atomically increment an integer in a document in Azure DocumentDB

老子叫甜甜 提交于 2019-12-10 14:49:07
问题 How can I atomically increment an integer in a document in Azure DocumentDB? The increment operation must be atomic in the presence of concurrent writers. No lost increments are allowed (they would be possible in a naive read-modify-write algorithm). 回答1: From the documentation: How does DocumentDB provide concurrency? DocumentDB supports optimistic concurrency control (OCC) through HTTP entity tags or ETags. Every DocumentDB resource has an ETag, and DocumentDB clients include their latest

Creating and comparing dates inside CosmosDB stored procedures

不想你离开。 提交于 2019-12-10 14:19:46
问题 There is limited guidance for CosmosDB stored procedures and their handling of new Date() and the comparison of dates. The following code is a CosmosDB stored procedure to 'freeze' the writing of documents after a given time. The property currentDoc.FreezeDate is in ISO-8601 format, e.g. '2017-11-15T13:34:04Z'. Note: this is an example of the situation I'm trying to understand. It is not production code. function tryUpdate(newDoc) { __.queryDocuments( __.getSelfLink(), { /* query to fetch the

search by substring in documentDB

≡放荡痞女 提交于 2019-12-10 14:18:48
问题 this is the sample documentDB document, I want to get all the documents who failed in one or more subjects I found something like SELECT * FROM students s JOIN c IN s.subjects WHERE c.result = "pass" I want to retrieve by using c# code { "id": "0066a253-f042-4213-b06e-65b1ea1e49aa", "name": "Sunny", "rollNo": 123, "class": "2nd", "section": "B", "Department": { "name": "CSE", "id": "cse", "subjects": [ { "id": "subject-1", "marksObtained": 66, "maxMarks": 100, "result": "pass" }, { "id":

How do you initialize DocumentDB client as a Singleton in a dotnet core application

℡╲_俬逩灬. 提交于 2019-12-10 14:16:39
问题 I am building a MVC Web application in .net core and will be using CosmosDB with the DocumentDB API. I keep reading that for preformance you should Use a singleton DocumentDB client for the lifetime of your application Note that each DocumentClient instance is thread-safe and performs efficient connection management and address caching when operating in Direct Mode. To allow efficient connection management and better performance by DocumentClient, it is recommended to use a single instance of

Correct way to check if DocumentDB object exists

元气小坏坏 提交于 2019-12-10 13:23:11
问题 In Microsoft examples I saw two ways to check if DocumentDb object like Database, DocumentCollection, Document etc. exists : First is by creating a query: Database db = client.CreateDatabaseQuery().Where(x => x.Id == DatabaseId).AsEnumerable().FirstOrDefault(); if (db == null) { await client.CreateDatabaseAsync(new Database { Id = DatabaseId }); } The second one is by using "try catch" block: try { await this.client.ReadDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName)); } catch

Azure DocumentDB Owner resource does not exist

谁都会走 提交于 2019-12-10 12:43:50
问题 I having the same error icrosoft.Azure.Documents.DocumentClientException: Message: {"Errors":["Owner resource does not exist"]} , this is my scenario. When I deployed my webapp to Azure and try to get some document from docDb it throws this error. The docdb exists in azure and contains the document that i looking for. The weird is that from my local machine(running from VS) this works fine. I'm using the same settings in Azure and local. Somebody have and idea about this. Thanks 回答1: Owner

.NET - c# - Cross partition query is required but disabled trouble on DocumentDB data access

有些话、适合烂在心里 提交于 2019-12-10 12:39:24
问题 I have written the following code to fetch a record from the DocumentDB private static void QueryDocuments1(DocumentClient client) { IQueryable<SearchInput> queryable = client.CreateDocumentQuery<SearchInput>(UriFactory.CreateDocumentCollectionUri(DocumentDBName, DocumentDBCollectionName)) .Where(x => x.Receiver == "8907180"); List<SearchInput> posts = queryable.ToList(); } And it is showing the following error on the code line List<SearchInput> posts = queryable.ToList(); {"Cross partition

Delete Documents from CosmosDB based on condition through Query Explorer

血红的双手。 提交于 2019-12-10 12:31:54
问题 What's the query or some other quick way to delete all the documents matching the where condition in a collection? I want something like DELETE * FROM c WHERE c.DocumentType = 'EULA' but, apparently, it doesn't work. Note: I'm not looking for any C# implementation for this. 回答1: I want something like DELETE * FROM c WHERE c.DocumentType = 'EULA' but, apparently, it doesn't work. Deleting documents this way is not supported. You would need to first select the documents using a SELECT query and

unable to search child object fields in azure search services(documentdb)?

回眸只為那壹抹淺笑 提交于 2019-12-10 12:19:29
问题 I am very new to azure search, basically i have created database and one collection this collection have few documents, also i have created one index . I am using REST API to search documents, 1) my rest api service is given below . GET https://xxxx.search.windows.net/indexes/[xxx]/docs?search=xxx&searchFields=xxxx&api-version=2015-02-28 2) My document is :{ "abc":"abcvalue", "xyz": { "key":"value", "kay1":"value1" } } Search result out put is : { "@odata.context": "https://xxx.search.windows