![word-image-10740-1.png](https://quantinsightsnetwork.com/wp-content/uploads/2024/06/word-image-10740-1.png)
Easily scale up or scale down your Fabric Capacity using Power Automate (Via email)
Following on from my previous blog post (Stop and start your Fabric Capacity using Power Automate) I got a question from Tristan as shown below!
I always enjoy a good challenge and I got it working! In this blog post I will use the same method where I am sending an email to scale up or scale down my Fabric Capacity.
The good news is that this works if the Capacity is paused or running (It might take a bit more time when running).
Before completing the Power Automate flow, I first needed to get the Fabric Capacity details which I will use in the flow steps.
I logged into the Azure Portal and went to my existing Fabric Capacity, and I then got the following details:
- Subscription
- Resource Group
- Resource Name which is also my Fabric Capacity Name
This is what it looks like in the Azure Portal.
I wanted to use a Service Principal account for authentication, this makes it secure and also removes user access to the Fabric Resource.
To do this I did the following:
What I then did was to create the flow with the following steps as explained below.
- The first step I created was to look for an email sent to myself where in the Subject Line it contains “Scale Capacity:”
- NOTE: Because I am extracting the values directly after the start of the subject “Scale Capacity:” make sure to keep it in the same format both for the flow and when sending the email.
- The next step is where I am searching for the subject to only extract the Capacity size
- The code I am using is the following
- For example if I wanted to scale it to an F4, my subject in my email would be “Scale Capacity:F4”
- Next, I created some Variables as it is easier to define and populate the variables which can then be re-used in subsequent steps. As well as if I need to use this flow for another capacity, I can just update the variables.
- I created the following variables below.
- Capacity_Size
- This is using the size I got from the previous step
- VAR Fabric Capacity Name
- This is my Fabric Capacity Name
- TimeZone
- This is my local time zone so that I can offset the UTC Time zone which is the default time zone for Power Automate.
- I then added the additional variables below which are needed when scaling the fabric capacity up or down
- NOTE: All the details are from the Fabric Capacity Details in the previous section.
- Capacity_Size
- I created the following variables below.
- I am also using Azure Key Vault, to ensure that no sensitive details are stored in clear text.
- In the next step is where I am going to use the Azure API to scale the Fabric to the size I specified in the subject of my email.
- 1. This is the URI which is required to connect to the right Azure resources.
- In here I used my previous variables to pass through the valid details
- SubscriptionName, ResourceGroupName and FabricCapacityName
- In here I used my previous variables to pass through the valid details
- 2. The Method I needed to use is PATCH
- 3. The content-type must be set to JSON
- 4. In the body is where I am specifying that it is an SKU and the name is the size of the SKU.
- Which in my example is an F4
- There are also the authentication details below, which in my example I used my Service Principal.
- I then put in a delay as it sometimes can take some time for the scaling to complete.
- Next I wanted to confirm what the status of my Fabric Capacity is.
- To do this, I created the following step to check the status.
- I searched for “Read a Resource”
- As shown below I selected my Subscription from the dropdown menu.
- I also selected the Resource Group from the dropdown menu.
- I also selected the Resource Provider from the dropdown menu.
- For the Shortcut Resource Id, I put in “capacities/” and then selected my variable called “FabricCapacityName” from above.
- And finally, I put in the Client API Version which is “2023-11-01”
- The steps was to send an email out the status of the Capacity so that I can confirm the size.
- Then in the send email step I put in the following details
- Number 1 is where I am inserting the Status check from the Capacity with the code below.
- Number 2 is where I am getting the SKU Size
- Number 3 is where I am getting the status of the Capacity
- Number 4 is where I am then using my variable from earlier called “TimeZone” to offset the DateTime so that is current for my time zone, which is GMT + 10 (I like to live in the future!)
- Number 5 is where I am getting the SKU Size
- I then saved my Flow.
The final steps are to test the flow to make sure that it will start or stop as expected when I send the email.
- The first email test is to scale up the capacity.
- The flow then ran, and I got the following email back giving me the Capacity Status and size
- I also then went into the Azure Portal to make sure that it had indeed scale to the specified size.
In this blog post, I have shown you how to scale your Fabric Capacity
I hope you found this blog post useful.
And if you have any questions or suggestions, peace in the comments below.
Here is the link to the flow I created if you wanted to use this in your organization.
FourMoo_FabricCapacity-ScaleUporDown.zip
Thanks for reading!
Be the first to comment