Welcome back to my channel. If you have watched my previous videos, you already know that I've published some solutions with Azure LogicApps to automate the process of "Pausing" and "Resuming" our Fabric capacities to manage the associated costs. In this video, I will explain another scenario where you can scale the capacity up and down in a time frame during the day.
Hi, my name is Soheil Bakhshi with a very warm welcome from biinsight. com. In today's video, I walk you through the steps required to automate scaling our Fabric capacity.
So during a time frame, we scale the capacity up to leverage more horsepower and after that time frame, we can scale it down. As mentioned before, I have posted some other videos regarding pausing and resuming Fabric capacities, so the combination of the two can give us optimum performance and managing the costs. Here's the thing, these methods will only work for Microsoft Fabric "F" capacities, not the reservation capacities, also they will not work with Power BI Premium capacities.
If you also follow my web log biinsight. com, you may have already read the blog post that I've published a couple of months ago about the same topic of scaling and down a scaling Fabric capacity using LogicApps. But here's the thing, back then I didn't notice that.
this method that I'm using in LogicApps s can cause some issues. It can override your administration settings or any kinds of tags if you have added any tags to your Fabric capacity. In this video I go through the entire process and I'll show you how to fix those issues, so stay tuned.
Let's head to Azure Portal through portal . azure. com and create a new LogicApps.
Now let's start just typing LogicApps. Click Create LogicApps and then ensure to select the consumption multi tenant and then click Select. I select my subscription, resource group and app name and also the region.
Click "Preview and Create" and after that click "Create". After the LogicApps is created, I click on the "Go to Resource" button to navigate to my LogicApps. Now let's implement our solution by clicking on the "Edit" button.
I now want to add a trigger. And the interval would be 1 hour, and time zone is New Zealand. So I find my time zone and I select it Auckland and Wellington, and start time can be any date and time.
I put it just 1st of September for now and I'll go to the settings and click the "Add" button to add some trigger conditions. I want the trigger to only fire LogicApps workflow on weekdays which. Monday to Friday.
So I use this expression that looks at Monday to Friday to get a LogicApps running. I also want my LogicApps to run only between 1:00 to 3:00 PM every day. This method would help to manage the costs of my LogicApps.
Instead of running every single hour during a day, I can just run it for a couple of hours instead of the entire day. Let's see how it works. I get the hour of my local time and turn it to integer and then.
Sure that it is greater than or equal to 13 and I ensure that the same logic goes well when it is less than 15, which is 3:00 PM. Now I just select and copy the first part of the code. And.
Paste it into the first condition. Then I click the add button to add another condition. I noted that I made a mistake.
Let's run the trigger between 1:00 and 5:00. So that's 13 and 17. That's good.
Let's grab the expression and paste it into the second condition. The next step is to get some information about my Fabric capacity or use reader resource and I'll select my subscription and the resource group. Also the provider is Microsoft Fabric.
I add my short resource audio which is capacities dot capacity name and client API version. Which is super important. I now add another action which is a condition.
I add a condition, I rename it to condition Check Capacity status. I want to check the capacity of status. I want to ensure that the capacity is running.
Because scaling up and down using Logic Apps using the Azure Resource Manager connectors requires the capacity to run. So I use this expression to check the status of the capacity. I click Add and condition is equal to pause.
Now I want to add another condition to ensure that if the capacity is not paused, it is running between 2:00. To 4:00 PM so I check the time of the day. I use this expression to get the error part of the day.
I click add and then the condition must be greater or equal to 14 which is 2 PMI missed the conditions so it's greater than or equal. And I add another item, add a row and then. I use exact same expression click add but this time must be smaller than or less than or equal to 16 which is 4.
Now if this condition is true which means I am between the agreed time frame, I want to scale up my capacity. So I use the create or update a resource. I just rename it to offscale skew.
I select my subscription. The resource group that I have my capacity stored in Resource provider is Microsoft Fabric short resource ID is capacities slash capacity name declined API. Version is 1st of November 2023.
To scale up the capacity we need to set up some more parameters. So I click on show all and then I select skew name and location and click on somewhere else. For the value of a skew by adding F 8 and for the location Southeast Asia.
Remember this location is the location of my Fabric capacity which I copied from the Fabric capacity properties. So far the solution should work as expected and upscale the capacity from F2 to F8 if the time of running the LogicApps workflow is between 2:00 to 4:00. But if the condition is false, I want to keep the capacity in F2 skewed so.
So I only need to copy this operation and paste it into the false condition by clicking button and click paste. I just rename the skew to downscale skew and changing the skew to F2 and that is it. The next step is just to save the solution.
Now I go back and resume my Fabric capacity by clicking on the resume button. And then click yes. As you can see, this capacity has two tags and now let's check the capacity administrators.
By clicking on Capacity Administrators, I can see that there are three administrators assigned to this capacity. I can also find the capacity administrators in Fabric Admin portal by clicking on the settings and then Admin portal. And from the admin portal, I click on the capacity settings, then click the Fabric Capacity tab.
From there I can select my Fabric capacity by clicking on it and then select admin permissions and there I can see my Fabric administrators. Now let's switch back to LogicApps and run our workflow by clicking Run and then run again to see the progress. I click on the refresh button to show me the run status.
Let's click on the Run status. And see what happens. As you can see, my capacity should have been over scaled.
Let's just switch back to Fabric. And as you can see, the admins are gone. Let's check on Azure portal.
As you can see, the Fabric is upscaled to F8 but the tags are gone. And what about the admins? Let's have a look.
As we expected, the admins are also gone. Let's dig deeper and see what the issue is. Our switch to LogicApps run history for investigating more.
Let's select the action in here. Let's Scroll down and on the outputs. As you can see, I have all of my e-mail addresses hereand scrolling down, I can also find out the tags over here.
So the reader resource reads the admins and the text, so we can use its output to fix the issue. Let's see how we go back to our LogicApps and click edit and now we are going to fix it. The fix is pretty simple, we just need to get the information from the reader resource and store it into a variable and use that variable in create or update a resource later to upscale or downscale our capacity.
So I click on the plus button after reader resource and add an action and look for initialised variable and select the initialise variable overhere which adds a variable after. Read the resource or rename it to get admins. Or just add a name, let's say admin.
The type the data type should be array because if you remember data type for the Fabric administrators was array and for the value. I use this expression to get the members of the administration part of the properties from the reader resource. Then I click add.
OK, now we just need to use this variable in the creator update resource. We just need to add another parameter which is the properties. So I just use the dropdown and take the properties.
The syntax of the properties accepts a Jason log administration and then members. As you can see I have three members over here and that member has actually an array. So let's delete this part.
And copy the entire code. And I just use it into the properties. Just paste it over here.
Now here's the three in front of the member. I just use the variable by clicking the dynamic content button and select admins, which is the variable that we created before. I just now need to take the exact same steps for the downscale operation.
So I just click on the operation, add properties again and paste code over here. And finally I hit the variable, the admins variable. And finally I save the solution.
Now let's check and see how it works. Let's switch back to Fabric admin portal and add some administrators to just test the solution and see if it works. So I just add "System Administrator" "Alan Deyoung" and "Megan".
And I click apply. Now let's just double check our Fabric "Capacity administrators" and Azure Admin portal by clicking on the "Capacity administrators". Yep, they're all good.
So we have added all three administrators. Now let's downscale the capacity manually. So I go change size and set it to F2 and I'll click resize.
And wait for it to go through. Yep, it went through. So it is active and it is F2.
So all good, now let's switch back to Azure LogicApps and run the solution. Click refresh to get the run history and let's refresh it again. Yeah, it is successful now and let's see the run.
Everything looks good and it is now upper scale to an F8. Let's look at the properties. And a body, Yep, as you can see, we preserve the capacity administrators.
Now this is the moment of truth. Let's double check and see if the admin settings are actually preserved. I refresh the page and let's check the admin permissions again.
As you can see, the admin permissions are preserved. Now we have a fully working solution in LogicApps to upscale and downscale our Fabric capacity without losing our administration settings. As we previously mentioned, this solution will only preserve the administration settings.
If you have some tags that you also want to preserve, you can use the same method. That's pretty much it. In this video, we have learned how to open, scale, and downscale our Fabric capacity during a time frame a day.
I originally wanted to cover the use cases in this video, but the video will turn into a very long 1, so I decided to cover it in another video, so stay tuned for that. Here's the thing, you can achieve the same thing with different technologies. Such as running APIs within Runbooks on Azure or using PowerShell or any other methods that you would like.
But for me Azure LogicApps is the tool of choice because it gives me a lot of flexibility and it has a very nice UI and it saves a lot of implementation time for me. I hope you find this video helpful and see you in the next one.