This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.Cosmos; | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Threading.Tasks; | |
// Use the transactional batch capability in .NET SDK V3.4 or higher | |
namespace CosmosBatchSample | |
{ | |
class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scaling throughput (RU/s) using V3 SDK | |
static async Task ScaleThroughputDemo_SDKVersion3() | |
{ | |
// Get reference to container | |
var container = cosmosClient.GetContainer(databaseId, containerId); | |
// Read value of current throughput (RU/s) | |
var currentThroughput = await container.ReadThroughputAsync(); | |
var newThroughput = (int)currentThroughput * 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.Cosmos; | |
using Microsoft.Azure.Cosmos.Fluent; // Use the new fluent namespace | |
using System.Threading.Tasks; | |
// Creating a new CosmosClient and Container using the fluent builder pattern | |
namespace CosmosDotnetSDKGetStarted | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scale fixed container using partition key in .NET V3 SDK | |
public static async Task ScaleNonPartitionedContainer() | |
{ | |
using (var cosmosClient = new CosmosClient(endpoint, key)) | |
{ | |
//Get reference to existing fixed container | |
var container = cosmosClient.GetDatabase(databaseId).GetContainer(containerId); | |
// Add item to container without partition key | |
var user = new User() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.Cosmos; | |
using System; | |
using System.Threading.Tasks; | |
//Getting started with .NET SDK V3 | |
namespace CosmosDotnetSDKGetStarted | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using the stream API to read data, in the context of an ASP.NET Web API | |
namespace CosmosWebAPI.Controllers | |
{ | |
[Produces("application/json")] | |
[Route("api/ProductReview")] | |
// GET: api/ProductReview/productId/continuationToken | |
[HttpGet("{productId}/{continuationToken}", Name = "Get")] | |
// using the new stream api | |
public async Task<HttpResponseMessage> Query(string productId, string continuationToken) |