Stop and start your Fabric Capacity using Power Automate
Stop and start your Fabric Capacity using Power Automate
With Fabric Capacities trial coming to an end, you need to make sure to stop and start Fabric Capacities.
In my blog post below, I am going to show you how I can start or stop my Fabric Capacity by simply sending an email to myself with the details in the Subject Line to start or stop the capacity.
Fabric Capacity Details
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
- MVP
- Resource Group
- MVPN-RG_Demo
- Resource Name which is also my Fabric Capacity Name
- f2ause
This is what it looks like in the Azure Portal.
Creating the Flow
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 “Fabric Capacity”
- 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.
- 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.
- VAR Fabric Capacity Name
- I created the following variables below.
- Before deciding to start of stop the Fabric Capacity I needed to know what the current 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”
- Next, I created 2 Conditional steps, the reason I did this is because it is easier to control if I need to start or stop the capacity instead of nesting them.
- I searched for Condition step
- The first conditional step is if the email is to start the Capacity and the capacity is currently stopped or paused.
-
- Number 1 is where I selected the Subject from the Object picker as shown below.
- Number 2 is where I put in the following code below in the Expression Builder, which will extract the Status from the Capacity Status step
-
body('Check_Fabric_Capacity_Status')?['properties']?['state']
-
- Number 1 is where I selected the Subject from the Object picker as shown below.
- If both above equal to TRUE, meaning the email says start and the Capacity status is set to Paused then start the Capacity.
- I searched for the step called “Invoke resource operation”
- If this is the first time using the Azure Resource Manager, you will need to sign in
- I then configured the step as shown below.
- Number 1 from above is where I selected my Subscription from the dropdown menu.
- Number 2 is where I selected the Resource Group from the dropdown menu.
- Number 3 is where I selected the Resource Provider from the dropdown menu.
- Number 4 is where I put in the Shortcut Resource Id, I put in “capacities/” and then selected my variable called “FabricCapacityName” from above.
- Number 5 is where I put in the Client API Version which is “2023-11-01”
- Number 6 is where I put the Action Name to “resume”, which will start the capacity.
- The first conditional step is if the email is to stop the Capacity and the capacity is currently stopped or paused.
-
- Number 1 is where I selected the Subject from the Object picker as shown below.
- Number 2 is where I put in the following code below in the Expression Builder, which will extract the Status from the Capacity Status step
-
body('Check_Fabric_Capacity_Status')?['properties']?['state']
-
- Number 1 is where I selected the Subject from the Object picker as shown below.
- If both above equal to TRUE, meaning the email says start and the Capacity status is set to Start then start the Capacity.
- I searched for the step called “Invoke resource operation”
- If this is the first time using the Azure Resource Manager, you will need to sign in
- I then configured the step as shown below.
- Number 1 from above is where I selected my Subscription from the dropdown menu.
- Number 2 is where I selected the Resource Group from the dropdown menu.
- Number 3 is where I selected the Resource Provider from the dropdown menu.
- Number 4 is where I put in the Shortcut Resource Id, I put in “capacities/” and then selected my variable called “FabricCapacityName” from above.
- Number 5 is where I put in the Client API Version which is “2023-11-01”
- Number 6 is where I put the Action Name to “suspend”, which will stop the capacity.
- I searched for Condition step
- The final 2 steps I did was to check the Fabric Capacity again, so that I can email out the status of the Capacity so that I can confirm if it started or stopped as expected.
- I copied and pasted the step called “Check Fabric Capacity Status” and renamed it to “Check Fabric Capacity Status Again” (Yes very original I know 😊)
- 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.
-
-
body('Check_Fabric_Capacity_Status_Again')?['properties']?['state']
-
-
- Number 2 is where I am once again putting the capacity status into the body.
- Number 3 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!)
-
addHours(utcNow(), variables('TimeZone'))
-
- I then saved my Flow.
Testing the 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 start the capacity, I sent the following email
- The flow then ran, and I got the following email back once the Capacity had started.
- I also then went into the Azure Portal to make sure that it had indeed started.
- The flow then ran, and I got the following email back once the Capacity had started.
- The first email test is to stop the capacity, I sent the following email
- The flow then ran, and I got the following email back once the Capacity had stopped or paused.
- I also then went into the Azure Portal to make sure that it had indeed started.
- NOTE: It sometimes can take a minute or three for the capacity to be stopped or paused.
- The flow then ran, and I got the following email back once the Capacity had stopped or paused.
Summary
In this blog post, I have shown you how to start or stop your Fabric capacity via email.
I hope you found this blog post useful.
And if you have any questions or suggestions, peace in the comments below.
Here a link to the Flow if you want to import this: StartorStopFabricCapacityfromEmail_FourMoo.zip
Thanks for reading!
[…] Gilbert Quevauvilliers saves some money: […]
[…] on from my previous blog post (Stop and start your Fabric Capacity using Power Automate) I got a question from Tristan as shown […]