Closed VincentCotineau closed 4 months ago
Thanks for the feedback. I made that change to support working with folders with characters in the path like square brackets (common in workspace names). Import-FabricItems is already recursively searching for all the .pbir and .pbism files in the provider folder, you do not require to search for the .Report and .SemanticModel.
For example, before if you did something like: Import-FabricItems -path "c:\temp\Project [dev]\PBIP" it wouldnt work and user must know that he should escape the square brackets.
Thanks for the reply Rui.
I was using this in way that the path provided was matching
$PBIPArtifactName = $datasetName
$pbipFilePathSemanticModel = "$ArtifactRoot\$PBIPArtifactName.SemanticModel"
$pbipFilePathReport = "$ArtifactRoot\$PBIPArtifactName.Report"
#Publishing Semantic Model
$semanticModelImport = Import-FabricItems -workspaceId $groupId -path $pbipFilePathSemanticModel
#Publishing Report
Import-FabricItems -workspaceId $groupId -path $pbipFilePathReport -itemProperties @{"semanticModelId"=$semanticModelImport.Id}
So that no wildcard is given, and the objects are found. I found that way in the readme here : (https://github.com/microsoft/Analysis-Services/tree/aefeb2662e358cf4d0ca131b37824180bf26a3b7/pbidevmode/fabricps-pbip) But now i get antoher error :
2024-06-28T14:05:32.8934130Z [31;1m[31;1mItem API dont support byPath connection, switch the connection in the *.pbir file to 'byConnection'.[0m
2024-06-28T14:05:32.8942375Z [31;1m[31;1mAt D:\a\r1\a\modules\FabricPS-PBIP.psm1:787 char:29[0m
2024-06-28T14:05:32.8943844Z [31;1m[31;1m+ … throw "Item API dont support byPath connection, switch th …[0m
2024-06-28T14:05:32.8944596Z [31;1m[31;1m+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
2024-06-28T14:05:32.8945571Z [31;1m[31;1m+ CategoryInfo : OperationStopped: (Item API dont suppo… to 'byConnection'.:String) [], RuntimeException[0m
2024-06-28T14:05:32.8946115Z [31;1m[31;1m+ FullyQualifiedErrorId : Item API dont support byPath connection, switch the connection in the *.pbir file to 'byConnection'.```
This new error i don't understand. Maybe you can help ?
A few weeks ago I launched another commandlet Import-FabricItem specific for item by item deployment giving you more control. See the example here: https://learn.microsoft.com/en-us/rest/api/fabric/articles/get-started/deploy-project#script-template
Yes this is also what I saw and tried to use. That's when I get the 'Item API dont suport byPath connection' which I don't understand...
The reason of the byPath error its because the API cannot solve the relative path in the byPath as Fabric Git integration does. Basically, when you deploy your report using an API you must resolve that connection to the semantic model. If you deploy both semantic model and report, then you should first deploy the semantic model, save the id and then deploy the report connected to the semantic model id. To avoid that error you must specify the semanticModel id in the -itemProperties of the import-fabricitem.
Import-FabricItems does what I described above automatically for you.
# Import the semantic model and save the item id
$semanticModelImport = Import-FabricItem -workspaceId $workspaceId -path $pbipSemanticModelPath
# Import the report and ensure its binded to the previous imported report
$reportImport = Import-FabricItem -workspaceId $workspaceId -path $pbipReportPath -itemProperties @{"semanticModelId" = $semanticModelImport.Id}
This is what I do. `$PBIPArtifactName = $datasetName $pbipFilePathSemanticModel = "$ArtifactRoot\$PBIPArtifactName.SemanticModel" $pbipFilePathReport = "$ArtifactRoot\$PBIPArtifactName.Report"
$semanticModelImport = Import-FabricItems -workspaceId $groupId -path $pbipFilePathSemanticModel
Import-FabricItems -workspaceId $groupId -path $pbipFilePathReport -itemProperties @{"semanticModelId"=$semanticModelImport.Id} `
I think the semanticModelId is never used later in the code.
$reportDatasetPath = (Resolve-path -LiteralPath (Join-Path $itemPath $pbirJson.datasetReference.byPath.path.Replace("/", "\"))).Path
$datasetReference = $datasetReferences[$reportDatasetPath]
if ($datasetReference)
{
# $datasetName = $datasetReference.name
$datasetId = $datasetReference.id
But i am not sure. But i already use the code you gave me as a reference
Looking at your code above it looks like you are using the Import-FabricItems with plural and not the singular Import-FabricItem that returns the imported object id.
Try change to the following, notice the name of the commandlet 'Import-FabricItem' and not 'Import-FabricItems'
$PBIPArtifactName = $datasetName
$pbipFilePathSemanticModel = "$ArtifactRoot\$PBIPArtifactName.SemanticModel"
$pbipFilePathReport = "$ArtifactRoot\$PBIPArtifactName.Report"
#Publishing Semantic Model
$semanticModelImport = Import-FabricItem -workspaceId $groupId -path $pbipFilePathSemanticModel
#Publishing Report
Import-FabricItem -workspaceId $groupId -path $pbipFilePathReport -itemProperties @{"semanticModelId"=$semanticModelImport.Id}
When you use 'Import-FabricItems' it handles the publishing of both semantic model and report, you only need to call it once and point to the folder that includes the subfolder for the semantic model and report. You can even point it to a folder with many reports and semantic models.
Oh well. I believe I should seen that myself. Thank you for your time, have a good week !
Hi, I am using the function Import-FabricItems as such :
$pbipFilePath = "$ArtifactRoot/$PBIPArtifactName.*"
Import-FabricItems -workspaceId $groupId -path $pbipFilePath
Since yesterday (Commit aefeb26), this function uses LiteralPath to try to find the files passed as parameters, and thus prevents from using wildcard characters and i find it troublesome because for example when we try to import pbip files we have to match several folders (PBIPArtifactName.SemanticModel and PBIPArtifactName.Report) and several files in those folders.