azure-cosmos-dotnet-v3 | NET SDK for Azure Cosmos DB for the core SQL API | Azure library
kandi X-RAY | azure-cosmos-dotnet-v3 Summary
kandi X-RAY | azure-cosmos-dotnet-v3 Summary
This client library enables client applications to connect to Azure Cosmos via the SQL API. Azure Cosmos is a globally distributed, multi-model database service. For more information, refer to
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of azure-cosmos-dotnet-v3
azure-cosmos-dotnet-v3 Key Features
azure-cosmos-dotnet-v3 Examples and Code Snippets
Community Discussions
Trending Discussions on azure-cosmos-dotnet-v3
QUESTION
I'm struggling to find a code example from MS for the v3 SDK for queries with paging, they provide examples for V2 but that SDK is a completely different code base using the "CreateDocumentQuery" method.
I've tried searching through GitHub here: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos.Samples/Usage/Queries/Program.cs
I believe I'm looking for a method example using continuation tokens, with the assumption that if I cache the previously used continuation tokens in my web app then I can page backwards as well as forwards?
I'm also not quite understanding MS explanation in that MaxItemCount doesn't actually mean it will only try to return X items, but simply limits the No. of items in each search across each partition, confused!
Can anyone point me to the right place for a code example please? I also tried searching through https://docs.microsoft.com/en-us/azure/cosmos-db/sql-query-pagination but appears to lead us to the older SDK (V2 I believe)
UPDATE (following comments from Gaurav below)
...ANSWER
Answered 2021-Aug-05 at 02:44Please try the following code. It fetches all documents from a container with a maximum of 100 documents in a single request.
QUESTION
In the samples for the Cosmos DB SQL API, there are a couple of uses of Database.ReadAsync() which don't seem to be doing anything useful. The remarks second in the method's documentation doesn't really indicate what it might be used for either.
What is the reason for using it in these cases? When would you typically use it?
ChangeFeed/Program.cs#L475 shows getting a database then calling ReadAsync to get another reference to the database
...ANSWER
Answered 2021-Jun-23 at 18:01You are correct that those samples might need polishing, the main difference is:
- GetDatabase just gets a proxy object, it does not mean the database actually exists. If you attempt an operation on a database that does not exist, for example, CreateContainer, it can fail with a 404.
- ReadAsync will read the
DatabaseProperties
and allow you obtain any information from there and also would succeed if the database actually exists. Does that guarantee that if I call CreateContainer right away it will succeed? No, because the database could have been deleted right in the middle.
So in summary, ReadAsync is good if you want to get any of the DatabaseProperties
or if you want to for some reason verify the database exists.
Most common scenarios would just use GetDatabase
because you are probably attempting operations down the chain (like creating a container or executing item level operations in some container in that database).
QUESTION
There is the "Undefined" class in Document DB SDK 2.# that I don't see the equivalent in Cosmos SDK 3.#. Please let me know if there is the equivalent. If not, what can I use for the replacement?
Thanks,
P.S. if there is any document describing how-to on this kind of topic, please let me know. I found some docs/samples on the github site very useful but I don't think it is comprehensive enough.
...ANSWER
Answered 2020-Nov-20 at 02:47There is no equivalent class in Cosmos SDK 3.#. If you want to read/create item without partition key, you can use PartitionKey.None
.
Example:
QUESTION
Attempting to upsert items into Cosmos DB from a .NET Core 3.1 console app on Windows 10 with C#.
JSON document looks like this:
...ANSWER
Answered 2020-Sep-24 at 14:05In your provided code, it seems like you're sending the partition key name "id" rather than the id
of the item. It should look like:
QUESTION
I currently have an item in the database that two users are trying to update. If one updates the item, I want the other user's update to fail then retry. I found a sample code for C# using the internal eTag, but I can't find the javascript equivalent.
Here is some pseudocode for what I want to do using the etag:
...ANSWER
Answered 2020-Jul-14 at 17:30I found the javascript equivalent for the etag and made the following fix:
QUESTION
I am trying to learn Docker and am building up a solution slowly as I go. I created an Azure Function App that has one Http endpoint exposed. I created the Docker file to build and run the solution in a linux container(image:mcr.microsoft.com/azure-functions/dotnet:3.0
, Debian image). I'm on a Windows machine.
I installed the Azure CosmosDB Emulator on my Windows machine and wanted to connect to it from the function app running in the linux container.
I am passing in the connection string for cosmos as an environment variable.
...ANSWER
Answered 2020-Jun-03 at 17:13Reference:
- https://github.com/Azure/azure-cosmos-dotnet-v3/issues/1551#issuecomment-634365001
- https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator#running-on-mac-or-linux
Following this guide, but the certificate needs to be a PFX, not CRT. It will ask you to set some password.
Step 2 - Place the cert somewhere you can copy or access from dockerFor example, I put it on a folder I can map to when booting Docker along with the code I wanted to run:
Step 3 - Get your machine's IP addressAs per https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator#running-on-mac-or-linux, I used ipconfig
and got my Windows IP.
In my case, I use one with the NET Core 3.1 SDK, the official one from https://docs.microsoft.com/en-us/dotnet/architecture/microservices/net-core-net-framework-containers/official-net-docker-images
I started the container with an interactive shell, and mapping localhost
to the IP I got on Step 3. This let's you use localhost in the connection string.
docker run -v /c/DockerSample:/DockerSample --add-host="localhost:192.168.1.15" -it mcr.microsoft.com/dotnet/core/sdk:3.1 /bin/bash
And I'm also mounting the folder where I saved the project and the certificate I want to import. This is not required, but I'm not fluent on Docker to know if there is a better way to pass the certificate.
After the shell starts, I basically run the commands described in the Emulator doc and the certificate gets added.
Step 5The Docker container should now have the required Cert to connect to localhost and you should not need the HttpClientFactory.
NOTE: Also there is a bug tracking HttpClientFactory not being used everywhere that is the source of your error https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1548
QUESTION
I am trying to access azure cosmos db account collection documents and also each document in collection. I had referred below link and changed all necessary cosmos db values like databaseid,container,itemid master key etc.,
Link:
But i am getting below error while running in Powershell.
Error:
...ANSWER
Answered 2020-Apr-16 at 04:19I tried the following code and it worked well for me. I was able to fetch the document details:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install azure-cosmos-dotnet-v3
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page