microsoft / Analysis-Services

Git repo for Analysis Services samples and community projects
MIT License
605 stars 416 forks source link

Import-FabricItem updates semantic model id in *.pbir, only for byPath #302

Closed dyutis closed 1 month ago

dyutis commented 1 month ago

Suppose I have exported a report from DevWorkspace. The definition.pbir file contains the pbiModelDatabaseName as byConnection. Now when trying to import the exported artifact to UatWorkspace, the semantic model id won't be updated dynamically as Import-FabricItem updates semantic model id in *.pbir, only for byPath.

Do we have any plan for enabling the same logic for byConnection too? or it shouldn't be done so? Any best practices to be followed here?

RuiRomano commented 1 month ago

The byPath its only used by Fabric Git and not Fabric APIs. We have plans for a batch import API where the byPath will be supported, but for now when using the Fabric Item API to create/update a report you must set the byConnection.

When deploying from Dev to UAT using Fabric API you must resolve the UAT semantic model connection and configure it in the definition.pbir file before deploying. Import-FabricItem have an 'itemProperties' parameter you could use to dynamically change the connection without having to modify the local file.

Import-FabricItem -itemProperties @{"semanticModelId"= [semanticModelId]}

dyutis commented 1 month ago

I have observed this condition "if ($pbirJson.datasetReference.byPath -and $pbirJson.datasetReference.byPath.path) { " in the module script: https://github.com/microsoft/Analysis-Services/blob/master/pbidevmode/fabricps-pbip/FabricPS-PBIP.psm1. In else condition it says for byConnection just send the original.

That is where I am having trouble with. When I exported the Report using the function "Export-FabricItem", it created byConnection in the definition.pbir for the Report. Since this belongs to byConnection, passing semanticModelId as -itemProperties not working while deploying to target workspace.

_{ "version": "4.0", "datasetReference": { "byPath": null, "byConnection": { "connectionString": "Data Source=powerbi://api.powerbi.com/v1.0/myorg/;Initial Catalog=SQLDBAzureDirectQuerypbip;Integrated Security=ClaimsToken", "pbiServiceModelId": null, "pbiModelVirtualServerName": "sobewowvirtualserver", "pbiModelDatabaseName": "", "name": "EntityDataSource", "connectionType": "pbiServiceXmlaStyleLive" } } }