-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerbi_refresh_runbook_env_setup.ps1
25 lines (21 loc) · 1.72 KB
/
powerbi_refresh_runbook_env_setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$resource_group_name = '<my_rg_name>'
$automation_account_name = '<my_ac_name>'
$automation_account_location = '<my_ac_location>'
$runbook_name = '<my_rb_name>'
$tenant_id = '<my_pbi_tenant_id>'
$group_id = '<my_wks_id>' # Workspace ID
$dataset_id = '<dst_id>' # Dataset to Refresh ID
$app_id = '<my_app_id>' # Service PRincipal ID
$Password = ConvertTo-SecureString 'ThisIsMyPassword' -AsPlainText -Force # Secret from Service Principal
Connect-AzAccount
# Create Azure Automation Account
New-AzAutomationAccount -ResourceGroupName $resource_group_name -Location $automation_account_location -Name $automation_account_name
# Create Azure Automation Runbook
New-AzAutomationRunbook -Name $runbook_name -ResourceGroupName $resource_group_name -AutomationAccountName $automation_account_name -Type PowerShell
# Create Variables for IDs
New-AzAutomationVariable -Name 'TenantID' -Description 'Power BI Tenant ID' -Value $tenant_id -AutomationAccountName $automation_account_name -ResourceGroupName $resource_group_name -Encrypted $false
New-AzAutomationVariable -Name 'GroupID' -Description 'Power BI Workspace ID' -Value $group_id -AutomationAccountName $automation_account_name -ResourceGroupName $resource_group_name -Encrypted $false
New-AzAutomationVariable -Name 'DatasetID' -Description 'Power BI Dataset ID' -Value $dataset_id -AutomationAccountName $automation_account_name -ResourceGroupName $resource_group_name -Encrypted $false
# Create Credential for SPN
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $app_id, $password
New-AzAutomationCredential -name 'SPN' -Description 'Service Principal' -Value $Credential -AutomationAccountName $automation_account_name -ResourceGroupName $resource_group_name