Skip to content

Commit 25a493b

Browse files
authored
Merge pull request #100309 from markjbrown/ps-scale-scheduler
scale cosmos on a schedule
2 parents 13212e8 + 724e3ef commit 25a493b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

articles/cosmos-db/TOC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,9 @@
869869
- name: Find request unit charge
870870
displayName: request units, RUs, RU, charge, consumption
871871
href: find-request-unit-charge.md
872+
- name: Scale using Azure Functions timer
873+
displayName: request units, RUs, RU, timer
874+
href: scale-on-schedule.md
872875
- name: Work with containers and items
873876
items:
874877
- name: Work with Cosmos DB data

articles/cosmos-db/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ landingContent:
152152
url: how-to-provision-container-throughput.md
153153
- text: Get the request unit charges
154154
url: find-request-unit-charge.md
155+
- text: Scale using Azure Functions timer
156+
url: scale-on-schedule.md
155157

156158
# Card
157159
- title: Build an app with SQL API
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Scale Azure Cosmos DB on a schedule by using Azure Functions timer
3+
description: Learn how to scale changes in throughput in Azure Cosmos DB using PowerShell and Azure Functions.
4+
author: markjbrown
5+
ms.service: cosmos-db
6+
ms.topic: conceptual
7+
ms.date: 01/13/2020
8+
ms.author: mjbrown
9+
---
10+
11+
# Scale Azure Cosmos DB throughput by using Azure Functions Timer trigger
12+
13+
The performance of an Azure Cosmos account is based on the amount of provisioned throughput expressed in Request Units per second (RU/s). The provisioning is at a second granularity and is billed based upon the highest RU/s per hour. This provisioned capacity model enables the service to provide a predictable and consistent throughput, guaranteed low latency, and high availability. Most production workloads these features. However, in development and testing environments where Azure Cosmos DB is only used during working hours, you can scale up the throughput in the morning and scale back down in the evening after working hours.
14+
15+
You can set the throughput via [Azure Resource Manager Templates](resource-manager-samples.md), [Azure CLI](cli-samples.md), and [PowerShell](powershell-samples-sql.md), for Core (SQL) API accounts, or by using the language-specific Azure Cosmos DB SDKs. The benefit of using Resource Manager Templates, Azure CLI or PowerShell is that they support all Azure Cosmos DB model APIs.
16+
17+
## Throughput scheduler sample project
18+
19+
To simplify the process to scale Azure Cosmos DB on a schedule we've created a sample project called [Azure Cosmos throughput scheduler](https://github.com/Azure-Samples/azure-cosmos-throughput-scheduler). This project is an Azure Functions app with two timer triggers- "ScaleUpTrigger" and "ScaleDownTrigger". The triggers run a PowerShell script that sets the throughput on each resource as defined in the `resources.json` file in each trigger. The ScaleUpTrigger is configured to run at 8 AM UTC and the ScaleDownTrigger is configured to run at 6 PM UTC and these times can be easily updated within the `function.json` file for each trigger.
20+
21+
You can clone this project locally, modify it to specify the Azure Cosmos DB resources to scale up and down and the schedule to run. Later you can deploy it in an Azure subscription and secure it using managed service identity with [Role-based Access Control](role-based-access-control.md) (RBAC) permissions with the "Azure Cosmos DB operator" role to set throughput on your Azure Cosmos accounts.
22+
23+
## Next Steps
24+
25+
- Learn more and download the sample from [Azure Cosmos DB throughput scheduler](https://github.com/Azure-Samples/azure-cosmos-throughput-scheduler).

0 commit comments

Comments
 (0)