Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pause/suspend an Azure Power BI Embedded Capacity using Azure Automation.
This Azure Automation runbook enables pausing/suspending of an Azure Power BI Embedded Capacity.
.PARAMETER resourceGroupName
Name of the resource group to which the capacity is assigned.
.PARAMETER azureRunAsConnectionName
Azure Automation Run As account name. Needs to be able to access the $capacityName.
.PARAMETER capacityName
Azure Power BI Embedded Capacity name.
-resourceGroupName myResourceGroup
-azureRunAsConnectionName AzureRunAsConnection
-capacityName mypowerbipremiumcapacity
Author: Dave Ruijter
Last Updated: Nov 2018
[string] $resourceGroupName = "rg-neu-powerbi-premium",
[string] $azureRunAsConnectionName = "AzureRunAsConnection",
[string] $capacityName = "macawpowerbipremiumcapacity"
filter timestamp {"[$(Get-Date -Format G)]: $_"}
Write-Output "Script started." | timestamp
$VerbosePreference = "Continue"
$ErrorActionPreference = "Stop"
#Authenticate with Azure Automation Run As account (service principal)
$runAsConnectionProfile = Get-AutomationConnection -Name $azureRunAsConnectionName
Add-AzureRmAccount -ServicePrincipal -TenantId $runAsConnectionProfile.TenantId -ApplicationId $runAsConnectionProfile.ApplicationId -CertificateThumbprint $runAsConnectionProfile.CertificateThumbprint | Out-Null
Write-Output "Authenticated with Automation Run As Account." | timestamp
# Get the PBI Capacity object
$pbiEmbCap = Get-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName
Write-Output "PBI Capacity name found: $($pbiEmbCap.Name)" | timestamp
Write-Output "Current PBI Capacity status: $($pbiEmbCap.State), pricing tier: $($pbiEmbCap.Sku)" | timestamp
if($pbiEmbCap.State -ne "Paused")
Write-Output "PBI Capacity not paused. Pausing!" | timestamp
$pbiEmbCap = Suspend-AzureRmPowerBIEmbeddedCapacity -Name $pbiEmbCap.Name -ResourceGroupName $resourceGroupName
Write-Output "PBI Capacity paused." | timestamp
$pbiEmbCap = Get-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName
Write-Output "Current PBI Capacity sate: $($pbiEmbCap.State), pricing tier: $($pbiEmbCap.Sku)" | timestamp
Write-Output "PBI Capacity paused already. Exiting..." | timestamp
Write-Output "Script finished." | timestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment