top of page
Geo Bontognali

Automatically Pause your Microsoft Fabric Capacity

It’s already been over a year since Fabric hit General Availability, and companies are migrating more and more to Microsoft's new all-in-one data analytics platform. Something that might scare off new adopters, especially those trying to build something small, is the pricing model and the uncertainty surrounding the predictability of costs and usage with Fabric. However, in reality—especially compared to something like Azure Data Factory—the prediction of costs with the Capacity model has been significantly simplified.


In this article, we’re going to explore how you can automatically control your Capacity and even turn it off during nights or weekends, making Fabric an affordable solution even for smaller deployments.


Fabric Capacities

Let’s briefly discuss what Capacities are. If you’re reading this article, you probably already know what Fabric is, but let’s quickly quote Microsoft on this:

"Microsoft Fabric is an end-to-end analytics and data platform designed for enterprises that require a unified solution. It encompasses data movement, processing, ingestion, transformation, real-time event routing, and report building."

Unlike other Microsoft Cloud services like Azure Data Factory (ADF) or Synapse Analytics, which use a pay-per-use model, Microsoft Fabric is based on Capacities.


A Capacity is a measure of compute power allocated and reserved for your Fabric Workspace. Capacities have a flat rate for a given compute power. Combining this, with the fact that capacities can be paused and as long as you can gauge how much compute power your solution is going to need, you’ll know exactly how much your solution will cost in advance.


You can find the costs for each capacity on the Azure Price Calculator: Microsoft Fabric - Pricing | Microsoft Azure


We’re not going to dive deep into the topic of Capacity in this article. There are many more concepts related to Capacities, like CUs, Bursting, Smoothing, etc. If you’re interested in these, check out this great in-depth explanation of capacities by Covenant:



Start small

For this example, we’ll use the smallest F2 Capacity. Currently, the monthly price for this Capacity is around 300€. However, if you don’t plan to use the solution outside of office hours and only during workdays—let’s say 160 hours a month—you can run Fabric for as little as 70€ a month. Not too bad for everything Fabric offers!


In the Azure Portal, you can easily stop your Fabric Capacity by selecting Pause.

Pause your capacity manually in the Azure Portal

This will deallocate your reserved Capacity, and the price per hour will drop to 0€.

Please note that when your Capacity is paused, you won’t be able to use any of the resources in your workspace, including Power BI.


Note: There are also some potential issues with stopping and restarting the Capacity, such as caching-related problems and other optimizations. If you’re interested in the technical details, check out the in-depth video mentioned before. For smaller deployments, these issues are usually not a concern anyway.


Do it once, do it twice, automate it

Currently Microsoft does not provide a built in scheduler to start, scale or stop your capacity in an automated manner, like they to for VMs for example. In order to automate this we will need to use Logic Apps.

We are going to run a flow every hour and compare the status of the capacity to what it should be at certain times. This could be further improved to run only at the times when the capacity actually need to be started or paused, but we are not going to worry about that here.


Begin with gathering the following information:

  • The resource group name where the Fabric Capacity resides

  • The subscription ID

  • The name of the Fabric Capacity

Now, before we start editing the flow, make sure to enable the managed identity for the Logic App. You can do this under Settings > Identity. This step is crucial as it allows the flow to authenticate securely and manage resources without requiring additional credentials.


This will create a managed identity for the Logic App. To grant it the necessary permissions to manage your Fabric Capacity, you’ll need to assign the Contributor role to this identity.

  1. Open your Fabric Capacity in the Azure Portal.

  2. Navigate to the IAM (Identity and Access Management) Roles section.

  3. Add the Contributor role to the newly created managed identity.

This will allow the Logic App to edit and control the Fabric Capacity as needed.


Now let's start creating the flow. For the trigger, we’ll use the Recurrence trigger set to an hourly interval. This will ensure the flow runs every hour to check and manage the Capacity.


Now we need to fetch the current status of the capacity. Add an HTTP GET Action, name it “Get current status” and configure the following URL (Replace the variables with the information gathered before):

Don’t forget to enable the managed identity for this action.

In the next step, initialize a variable to store the state of the Capacity. You can retrieve the status using the following formula:

body('Get_current_status').properties.state

The result will either be "Active" or "Paused".


Next, add a Condition, which we’ll call "Time to Run", to check if the current time falls within the defined running hours and workdays.



Here are the formulas used in the expressions. Note that these use UTC times, so don’t forget to adjust them to your local timezone if needed:

int(formatDateTime(utcNow(), 'HH')) # Time
dayOfWeek(utcNow()) # Day of the week

Now, on the True side of the condition, we’ll check if the Capacity state is "Active" or "Paused". If it’s already active, no action is needed. Otherwise, we’ll start it.


To start the Capacity, copy and paste the first HTTP GET request and modify it. Change the method to POST and use the following URL:

Note the "resume" at the end of the URL.


For the False side of the condition, do the same thing but use the "suspend" suffix instead. This will pause your Capacity.


This is it. Here the overview of the complete flow:


Commenti


bottom of page