Forum Discussion
Anonymous
7 years agoNot applicable
Power BI API via PowerShell fails in Azure DevOps
Hi all, I'm trying to automate the deployment of Power BI (and other modern DWH components) via Azure DevOps releases. I've created a PowerShell script that looks at the contents of a setup file ...
Jayendran
7 years agoSolution Sage
Hi Anonymous
Not sure that you aware of the Azure DevOps Extension called PowerBI Action. Using this you can do some operation easily with out having worry about powershell scripts.
If you still want to do some additional things , you can see the source code of the extension, where the author is also using powershell to build this extension.
The author put all the powershell cleanly in a function, as per that
Function Get-AADToken {
Param(
[parameter(Mandatory = $true)][string]$Username,
[parameter(Mandatory = $true)][SecureString]$Password,
[parameter(Mandatory = $true)][guid]$ClientId,
[parameter(Mandatory = $true)][string]$Resource
)
$authorityUrl = "https://login.microsoftonline.com/common/oauth2/authorize"
## load active directory client dll
$typePath = $PSScriptRoot + "\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
Add-Type -Path $typePath
Write-Verbose "Loaded the Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
Write-Verbose "Using authority: $authorityUrl"
$authContext = New-Object -TypeName Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext -ArgumentList ($authorityUrl)
$credential = New-Object -TypeName Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential -ArgumentList ($UserName, $Password)
Write-Verbose "Trying to aquire token for resource: $Resource"
$authResult = $authContext.AcquireToken($Resource, $clientId, $credential)
Write-Verbose "Authentication Result retrieved for: $($authResult.UserInfo.DisplayableId)"
return $authResult.AccessToken
}I'm also writing a detailed article for CICD for PowerBI using Azure DevOps,
But it's still in progress, I stil need some time to need these too :smileywink: