Updating RU value of a container in Cosmos DB from ADF pipeline

bharath nunepalli 41 Reputation points
2020-11-02T22:51:37.757+00:00

Hi,
I'm just curious to know whether anyone has tried updating the RU value of a container in Cosmos DB account using ADF pipeline.
If yes, please share the details.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,665 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,826 questions
0 comments No comments
{count} votes

Accepted answer
  1. KalyanChanumolu-MSFT 8,336 Reputation points
    2020-11-03T09:18:29.68+00:00

    @bharath nunepalli Welcome to Microsoft Q&A Forums and thank you for your interest in Azure products.

    The easiest way would be to use an Azure Function Activity in your ADF pipeline
    Here is a code snippet you could use in the Azure function for updating the container throughput. You can get the CosmosDB SDK here

     public static class Function1  
     {  
        private static Database database = null;  
      
        [FunctionName("Function1")]  
        public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)  
        {  
            log.LogInformation("C# HTTP trigger function for scaling a Cosmos Container.");  
      
            var databaseId = "samples";  
            var containerId = "container-samples";  
            var endpoint = "<Your endPoint Here>";  
            var authKey = "<Your authKey Here>";  
      
            using (CosmosClient client = new CosmosClient(endpoint, authKey))  
            {  
                database = await client.CreateDatabaseIfNotExistsAsync(databaseId);  
      
                Container container = database.GetContainer(containerId);  
                ContainerProperties containerProperties = await container.ReadContainerAsync();  
      
                int? throughputResponse = await container.ReadThroughputAsync();  
      
                // Change performance (reserved throughput) of CosmosContainer to 500 RU/s  
                await container.ReplaceThroughputAsync(500);  
            }  
      
            return new OkObjectResult("Scaling successful");  
        }  
    }  
    

    Do let us know if you have any further questions.

    ----------

    If an answer is helpful, please "Accept answer" or "Up-Vote" for the same which might be beneficial to other community members reading this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.