Disclaimer: This post will not cover what Microsoft Fabric is or how to use it.
Fabric is a unified data platform that offers shared experiences, architecture, governance, compliance and billing. Capacities provide the computing power that drives all these experiences. You can read more about fabric capacities here.
Imagine this: your Fabric trial is ending, and you’re still in the proof-of-concept phase to determine if Fabric is the right option for you. Managing your capacity efficiently is crucial, as you don’t want to incur unnecessary costs for unused capacity, especially during these testing or evaluation periods.
If you’re already using Fabric for production workloads, the strategy we will be discussing in this post won’t work for you, as you’ll likely require some available capacity at all times to support those workloads. You might be more interested in learning how smoothing and throttling processes work in Fabric to estimate your costs and how to use the capacity metrics app to monitor them.
For the rest of you who are still working in non-production environments, I’ll show you how to automatically pause your Fabric capacity when it’s not needed. This is particularly useful if you’re testing capabilities but won’t be running tests 24/7. So, how can you ensure you don’t forget to pause your capacity?
You might be wondering, what does it mean to pause your Fabric capacity? Is this even possible? The answer is yes, and I’ll show you how.
When we create a Fabric capacity in the Azure portal, we will see something like this, where you have an option to pause your capacity, so you’re not being charged for not using it.
But what if you forget to pause it for a couple of days?
That could lead to a significantly higher Azure bill. To prevent this, let’s create an automated way to pause your Fabric capacity.
Azure Logic Apps to the rescue
To accomplish this, we will be first creating a logic app in Azure, preferably within the same resource group as your Fabric capacity.
You can follow the instructions from here to create your logic app. Be sure to choose the Consumption
plan type instead of the Standard
plan type, as it is easier to use for beginners and you’ll only pay for what you use.
Before we begin designing the logic app, we need to grant the logic app access to modify the state of your Fabric capacity, as security is of the utmost importance. To enable this, navigate to the Settings > Identity
option of your logic app, and turn on the system-assigned managed identity.
Managed identities provide an automatically managed identity in Entra ID for applications to use when connecting to resources that support Entra ID authentication, without the need to store credentials in your code. This will allow the newly created logic app to securely interact with your Fabric capacity without needing explicit credentials.
Once we’ve enabled the managed identity, we need to give this identity read and write permission on your fabric capacity. In order to this, we will navigate back to our fabric capacity resource.
On the Add Role Assignment
page, select the Contributor
role under Privileged administrator roles
, as this role provides both read and write access to the Fabric capacity. Then, click Next
.
On the next page, select the managed identity of your logic app. Ensure it appears under Selected members
, then click Select
, followed by Next
. On the final page, simply click Review + assign
.
With that, we have successfully granted our logic app the necessary permissions to perform its task! Now, let’s begin. We have five easy steps to build this workflow, which should be followed preferably in order.
Designing the logic app
To start, navigate to the Logic app designer
, located under the Development Tools
setting in your logic app resource.
Create Parameters
Before we start adding triggers and actions, we need to define some parameters that will be used with our HTTP request actions later.
We will need to build our parameters as mentioned below by replacing your-subscription-id
, ** `your-resource-group-name** and
your-fabric-capacity-name` with your corresponding subscription ID, resource group name and fabric capacity name values. The first one parameter is to get the status of your Fabric capacity:
Name : $getfabricstatus
Type : String
Default Value : https://management.azure.com/subscriptions/your-subscription-id/resourceGroups/your-resource-group-name/providers/Microsoft.Fabric/capacities/your-fabric-capacity-name?api-version=2023-11-01
And the second one is to pause your Fabric capacity:
Name : $pausefabriccapacity
Type : String
Default Value : https://management.azure.com/subscriptions/your-subscription-id/resourceGroups/your-resource-group-name/providers/Microsoft.Fabric/capacities/your-fabric-capacity-name/suspend?api-version=2023-11-01
Make sure to save the logic app design at this stage to ensure your parameters are saved.
Create Recurrence Schedule Trigger
Once we have our parameters created, we can start the design of our logic app. When we create a logic app, we will always start with adding a trigger. This will define how often the logic app runs. You can set it to run daily, weekly, or at any other interval that suits your needs. This ensures that the logic app checks the status of your Fabric capacity at regular intervals.
To do this, click the Add Trigger
button located in the center of the canvas as indicated in the image below.
The Add a trigger
pane will open on the right side of the page. Here, you can search for the Schedule trigger and select the Recurrence
option from the two available choices.
You can then fill out the requested information according to your preference. In the image below, I have set up a recurring trigger to activate every weekday (Monday to Friday) at 12:00 PM and 6:00 PM in my time zone.
Add HTTP Action
Next, we will add an HTTP action. This action will make an HTTP request to the Fabric API to check the current status of your capacity. Configure the HTTP action with the appropriate method (GET, POST, etc.), URL, and authentication details to securely access the Fabric API.
Remember when we created the managed identity and assigned it the Contributor role? This is where we will utilize the read permission provided by the Contributor role.
Click Add an action
as indicated below to find the HTTP action we will be using in this step.
Search for the HTTP action in the search bar, and select the first option from the three available under the HTTP action on the Add an action
pane.
Click the lightning icon to open the drop-down list of previously created parameters, and select the first parameter, $getfabricstatus
, for the URI field. In the method field, choose GET
.
Then scroll to the bottom of the pane and add the Authentication
options in the Advanced parameters
section. This will add an Authentication section right below and select the following options:
Authentication Type : Managed Identity
Managed Identity : System-assigned managed identity
And with that we can securely query the status of the fabric capacity using the managed identity we had created previously.
Add Parse JSON Action
Once we receive a response from the Fabric API, use the Parse JSON action to process the data. The API request from the previous step will return a lot of information, and it’s up to us to choose which data points to work with. The Parse JSON action helps us extract specific details from the JSON response, such as the current status of the Fabric capacity.
To configure this action correctly, provide a sample JSON payload or schema in the Schema
section, which is provided below for you to copy. For the Content
field, click the lightning icon again and select Body
from the output of the previous step.
Content: Body
Schema:
{
"properties": {
"id": {
"type": "string"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"properties": {
"administration": {
"properties": {
"members": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"mode": {
"type": "string"
},
"provisioningState": {
"type": "string"
},
"state": {
"type": "string"
}
},
"type": "object"
},
"sku": {
"properties": {
"name": {
"type": "string"
},
"tier": {
"type": "string"
}
},
"type": "object"
},
"tags": {
"properties": {},
"type": "object"
},
"type": {
"type": "string"
}
},
"type": "object"
}
Add Condition Action
And now for our second-to-last action, we will add a Condition action to evaluate the status from the parsed JSON data. This condition will determine whether the Fabric capacity needs to be paused. For example, we will be setting the condition to check if the capacity status is not "paused."
To configure the Condition action, we will again use the lightning icon, to find the Body state
option from the output of the previous step.
Then we will need to change the is equal to
to is not equal to
and add the value of Paused
. The final result should look something like this:
If the condition is true (meaning the capacity is not paused), you can add actions in the True section to pause the capacity. If the condition is false (meaning the capacity is already paused), you can leave the False section empty or add a notification action to log that no action was needed.
In our case, we will add our final action, which will be another HTTP action, to the True section. This action will use the second parameter we defined, $pausefabriccapacity
.
Follow the same steps as for the previous HTTP action, but this time, use the $pausefabriccapacity
parameter and select the POST
method instead of the GET
method.
Important! Don’t forget to change the authentication settings as we did for the last HTTP action; otherwise, you might encounter an authentication error.
And with that, we are done with designing our logic app, and after some edits to the names of the steps, we should have a logic app configuration that looks like below.
After completing the setup, it’s important to test your logic app to ensure it functions as expected. Run a test, and once it executes successfully, verify that your Fabric capacity has indeed paused. This confirmation step is important to ensure that the automation works correctly and will help prevent unnecessary Azure charges.
With this setup, you now know how to automate the pausing of your Fabric capacity, giving you peace of mind and more control over your capacities.
Happy machine learning and data analyzing with Fabric!
Note: All images, unless explicitly mentioned, are taken by the author.