Forum Discussion
Autoscaling Power BI Embedded Gen 2
- 5 years ago
Sadly there is no very good advice or best practices. We thought a lot about how to solve this best. Our Solution are two alert rules on the Power BI Embedded Capacity:
Rule 1: "Whenever the maximum overload (gen2) is greater than or equal to 1000m" and "Whenever the maximum cpu (gen2) is greater than 85%"
Rule 2: "Whenever the maximum cpu (gen2) is lower than 40%"
Depending on the rule which gets activated we fire a PowerShell Runbook with parameter "up" or "down"which scales our embedded instance.
I'm a bit disappointed that a very nice feature like "autoscale" is activated and promoted on Power BI Premium but not Power BI Embedded. - 2 years ago
We had some issues with alert rules: sometimes they didn't resolve (we couldn't figure out why) and therefore didn't fire again.
Sadly our script disappered while we moved to a new repro. I tried to recap it from my mind, please try it in testing enviroment.
# Enable Managed Identity Enable-AzContextAutosave -Scope Process Connect-AzAccount -Identity # Set the resource group and the name of the Power BI Embedded resource $resourceGroupName = "<YourResourceGroupName>" $resourceName = "<YourResourceName>" $maxSKU = "A7" # Read the current SKU of the Power BI Embedded resource $pbiResource = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $resourceName # Extract the current SKU and increment it by 1 if it's below the maximum allowed SKU $currentSku = $pbiResource.Sku.Name $skuNumber = [regex]::Match($currentSku, "\d+").Value $newSkuNumber = [int]$skuNumber + 1 $maxSkuNumber = [int][regex]::Match($maxSKU, "\d+").Value # Ensure the new SKU does not exceed the maximum SKU if ($newSkuNumber -le $maxSkuNumber) { $newSku = $currentSku -replace "\d+", $newSkuNumber.ToString() # Update the SKU of the Power BI Embedded resource $updatedConfig = @{ "sku" = @{ "name" = $newSku "tier" = "PBIE_Azure" } } Set-AzResource -ResourceGroupName $resourceGroupName -ResourceName $resourceName -ResourceType "Microsoft.PowerBIDedicated/capacities" -Sku $updatedConfig.sku -Force # Output the new SKU Write-Host "Power BI Embedded resource has been updated to SKU $newSku." } else { Write-Host "The current SKU is already at or above the maximum permissible SKU ($maxSKU). No action taken." }Update: I'm sorry, I can't choose "powershell" as language, therefore the script looks like this.
Sadly there is no very good advice or best practices. We thought a lot about how to solve this best. Our Solution are two alert rules on the Power BI Embedded Capacity:
Rule 1: "Whenever the maximum overload (gen2) is greater than or equal to 1000m" and "Whenever the maximum cpu (gen2) is greater than 85%"
Rule 2: "Whenever the maximum cpu (gen2) is lower than 40%"
Depending on the rule which gets activated we fire a PowerShell Runbook with parameter "up" or "down"which scales our embedded instance.
I'm a bit disappointed that a very nice feature like "autoscale" is activated and promoted on Power BI Premium but not Power BI Embedded.
Hi dd8zc ,
I'm looking to implement something like what you have described to scale our embedded capacity both up and down, but am not too confident in my PS skills. Are you able to share the scripts that you used for both up and down? Another question that I'm having a hard time getting my head around: how often do you poll the capacity in order to decide when to trigger in either direction? I have read https://learn.microsoft.com/en-us/power-bi/developer/embedded/azure-pbie-scale-capacity but I don't quite get it.
Thanks for any pointers.
- dd8zc2 years agoHelper I
We had some issues with alert rules: sometimes they didn't resolve (we couldn't figure out why) and therefore didn't fire again.
Sadly our script disappered while we moved to a new repro. I tried to recap it from my mind, please try it in testing enviroment.
# Enable Managed Identity Enable-AzContextAutosave -Scope Process Connect-AzAccount -Identity # Set the resource group and the name of the Power BI Embedded resource $resourceGroupName = "<YourResourceGroupName>" $resourceName = "<YourResourceName>" $maxSKU = "A7" # Read the current SKU of the Power BI Embedded resource $pbiResource = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $resourceName # Extract the current SKU and increment it by 1 if it's below the maximum allowed SKU $currentSku = $pbiResource.Sku.Name $skuNumber = [regex]::Match($currentSku, "\d+").Value $newSkuNumber = [int]$skuNumber + 1 $maxSkuNumber = [int][regex]::Match($maxSKU, "\d+").Value # Ensure the new SKU does not exceed the maximum SKU if ($newSkuNumber -le $maxSkuNumber) { $newSku = $currentSku -replace "\d+", $newSkuNumber.ToString() # Update the SKU of the Power BI Embedded resource $updatedConfig = @{ "sku" = @{ "name" = $newSku "tier" = "PBIE_Azure" } } Set-AzResource -ResourceGroupName $resourceGroupName -ResourceName $resourceName -ResourceType "Microsoft.PowerBIDedicated/capacities" -Sku $updatedConfig.sku -Force # Output the new SKU Write-Host "Power BI Embedded resource has been updated to SKU $newSku." } else { Write-Host "The current SKU is already at or above the maximum permissible SKU ($maxSKU). No action taken." }Update: I'm sorry, I can't choose "powershell" as language, therefore the script looks like this.
- Sohrab2 years agoAdvocate II
dd8zc thank you so much!!
Over the holidays, I fought with the docs and powershell and runbooks, until I realized that the example script that MS has linked to is so outdated that it is unusable:
References in that script to:
Set-AzureRmContext
Get-AzureRmPowerBIEmbeddedCapacity
Update-AzureRmPowerBIEmbeddedCapacityneed to be replaced with
Set-AzContext
Get-AzPowerBIEmbeddedCapacity
Update-AzPowerBIEmbeddedCapacityI logged this GitHub issue hoping that someone will update the documentation. https://github.com/MicrosoftDocs/powerbi-docs/issues/4935
Question: though my alert rule for scale-down is simple, "if MAX(CPU) < 25%" check every 30 mins, lookback 30 mins, and though the rule condition UI shows that we are in that state, the scale-down rule never fires. Did you run into this? Our scale-up rule seems to fire immediately, as expected.
- dd8zc2 years agoHelper I
Have you tried as well with avg(CPU)? On our side this did the trick.