web-dev-qa-db-ja.com

プログラムによるPower BIレポートのPower BIレポートサーバーへの展開と接続文字列の変更

これらのファイルを手動でコピーしてサーバーにアップロードし、最後にレポートごとに各レポートのデータソース接続情報を変更せずに、Power BIレポートサーバーにPower BIレポートを展開する方法はありますか?顧客サイト。

例えば。 PowerBIレポートファイル-'Report_1'は、顧客サーバーS1、S2、S3などに展開する必要があります。

これらのファイルを手動でコピーしてサーバーにアップロードし、最後にレポートごとに各レポートのデータソース接続情報を変更します。これは、各顧客サイトでは実用的ではありません。

Power BI Report ServerへのPBIXレポートの展開を自動化し、データソース接続文字列を文法的に変更する方法

マイクロソフトは、2020年1月にAPIを使用して接続文字列を更新する機能をリリースします。

enter image description here

マイクロソフトは2020年1月に機能をリリースしますが、2019年には何らかの方法がありますか?接続文字列を更新する他の方法は?

Microsoftリンク

6
Mr. Bhosale

最後に、PowerBIで接続文字列を更新するための1つのトリックを発明しました。

最初にPowershellにPowerBI APIをインストールします。 Microsoft APIは、接続文字列を更新する機能を提供しませんが、ユーザー名を更新する権限を与えます。ユーザー名と接続文字列はどちらも暗号化された形式でデータベースに保存されます。したがって、ロジックは接続文字列をユーザー名に渡し、暗号化された文字列をデータベースの接続文字列列にコピーします。以下の例をチェックして、私がこのトリックを作成して発明した例を確認してください。ありがとうございました。

# Code By SB 2019
$ReportServerURI = 'http://localhost/PowerBIReports' # Input Local path of powerbi file
$filePath = "C:\12.pbix"                                # Input Local path of powerbi file
$PBIxfileName = "12"                                    # INput your Powerbi File Name
$FolderName ='NewDataset'                               # Input PowerBI server Folder Name Where you wann to deploy
$Username ='admin'
$password ='password'                          
$ReportServerName ='localhost\SQl2017'                  #input SQL server where POWERBI database installed
$ReportServerDatabase = 'ReportServerPowerBI'           #input PowerBi Database Name 

$ConnectionString ='data source=Client01\SQL2019;initial catalog=Client_SB_1'  # input New Connection String / Client ConnectionString

$FolderLocation = '/'
$FolderPath = $FolderLocation + $FolderName

write-Host "Deployment Started ..." -ForeGroundColor Yellow 
$session = New-RsRestSession -ReportPortalUri $ReportServerURI
Write-RsRestCatalogItem -WebSession $session -Path $filePath -RsFolder $folderPath -Description $Description -Overwrite
$datasources = Get-RsRestItemDataSource -WebSession $session -RsItem "$FolderPath/$PBIxfileName"
$dataSources[0].DataModelDataSource.AuthType = ‘Windows'
$dataSources[0].DataModelDataSource.Username = $ConnectionString 
$dataSources[0].DataModelDataSource.Secret = $password

Set-RsRestItemDataSource -WebSession $session -RsItem "$folderPath/$PBIxfileName" -RsItemType PowerBIReport -DataSources $datasources

$ID =  $dataSources[0].Id
$Query = " Update [DataModelDataSource] SET ConnectionString = Username From [dbo].[DataModelDataSource] Where DataSourceID ='" + $ID  + "' "

Invoke-Sqlcmd -Query $Query -ServerInstance CPMSUNRSQL17\CPMSRINST17 -Database ReportServerPowerBI

$datasources = Get-RsRestItemDataSource -WebSession $session -RsItem "$FolderPath/$PBIxfileName"
$dataSources[0].DataModelDataSource.Username = $Username
$dataSources[0].DataModelDataSource.Secret = $password
Set-RsRestItemDataSource -WebSession $session -RsItem "$folderPath/$PBIxfileName" -RsItemType PowerBIReport -DataSources $datasources

write-Host "Deployment Done . . ." -ForeGroundColor Green 
2
Mr. Bhosale

これは、必要な変更がパラメーターによって駆動できる場合にのみ機能します。 SQL Serverソースの場合、データベース、スキーマ、またはテーブル名を設定できます(サーバー名は設定できません)。

まず、クエリパラメータを使用してテストするようにクエリ定義を設定します。これの詳細は、データソースとシナリオによって異なります。これに関する情報は提供されていません。

次に、適切なREST APIUpdate Parametersメソッドを呼び出します-おそらくグループバージョン。

https://docs.Microsoft.com/en-us/rest/api/power-bi/datasets/updateparametersingroup

0
Mike Honey

を使用してPower BI Report Serverを展開し、Powershellを使用して ReportingServiceTools ライブラリを使用して接続やその他の設定を変更できます。PowerBI Report ServiceはSSRSなので、同じツールを使用してレポートを読み込んだり、データを変更したりできます接続など

ファイルのデプロイの例 および ここ

PBIXファイルで直接接続設定を変更することもできます。拡張子をpbixからZipに変更すると、内部を確認できます。

Power BI Internal structure 「接続」ファイルを開くと、JSON構造化ファイルを介した設定が含まれています

{"Version":1,"Connections":[{"Name":"EntityDataSource","ConnectionString":"Data Source=asazure://region.asazure.windows.net/somecubegoes her;Initial Catalog=SmartSpacesAnalysis;Cube=SmartSpacesModel","ConnectionType":"analysisServicesDatabaseLive"}]}

必要に応じて読み取り、変更できます

0
Jonee