Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
341 stars 44 forks source link

Adjust CosmosDB Offer at Database Level #51

Closed ijabit closed 5 years ago

ijabit commented 5 years ago

Is there any way through this library (or the SDK even) to adjust the scale of the new database level scaling feature (where you can have many collections share the same RU/s limit).

I did find this way of doing it in Powershell, and it works: https://github.com/PlagueHO/CosmosDB/blob/82199fe9df0e8648ab8829adaa9c938cbde1de66/src/lib/offers/Set-CosmosDbOffer.ps1

Elfocrash commented 5 years ago

Hello @ijabit,

Thanks for raising this. Yes indeed there is a way to do it in Cosmonaut.

You would have to use the CosmonautClient UpdateOfferAsync method.

In order to get the offer you want to update you simply use the QueryOffersAsync or QueryOffersV2Async methods.

The call would look something like this for the database:

var dbOffer = (await cosmonautClient.QueryOffersV2Async(x => x.ResourceLink == databaseSelfLink)).SingleOrDefault()

I will also create 2 methods (GetOfferForDatabaseAsync abd GetOfferV2ForDatabaseAsync) to make this easier, like I did with the Collections offers.

Does this help you?

ijabit commented 5 years ago

Yes! It's strange, if I search this repo for "offer" it doesn't show the QueryOffersAsync method, but if I search for "offers" it does. I also couldn't find it when I searched the documentation. It would probably be nice to document this method somewhere so people know its there.

Thanks!

Elfocrash commented 5 years ago

I added the methods and published a new release, 2.8.1. It will take about 30 minutes for Nuget to index the package, but feel free to use it once it's done.