Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kunal105
Regular Visitor

Reimporting a pbix file In Embedded workspace

 

I imported a pbix file which is in Direct Query Mode using provision sample and it worked fine. I get a reportId and DatasetId for this report. I hardcode the reportid for this pbix in an web application. Now I want to re upload a new version of the pbix while keeping the same ReportId. I used the provision sample again and use import with same dataset name but it creates a new report with a new dataset and reportid. How can I replace existing one?

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @kunal105,

 

There's an argument nameconfilict for PostImportWithFileAsync, and as per this github sample, the argument value "Overwrite" can be used to overwrite the existing pbix file.

 

The report id doesn't change in a overwritten import, thus it won't affect the report embedded somewhere in your application. Smiley Happy

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @kunal105,

 

There's an argument nameconfilict for PostImportWithFileAsync, and as per this github sample, the argument value "Overwrite" can be used to overwrite the existing pbix file.

 

The report id doesn't change in a overwritten import, thus it won't affect the report embedded somewhere in your application. Smiley Happy

 

Regards

TedPattison
Employee
Employee

I went through this and I found that you must delete the dataset with that dataset ID which effectively deletes everything about the previous PBIX upload including the report and the dataset which both have the same ID. Here's the method I wrote to delete the previous PBIX resources before I upload the new version of the same PBIX file.

 

 

 static void DeleteDataset(string workspaceCollectionName, string workspaceId, string datasetId) {
      using (var client = CreatePowerBIClient()) {
        var datasets = client.Datasets.GetDatasetsAsync(workspaceCollectionName, workspaceId).Result.Value;
        foreach (var dataset in datasets) {
          if (dataset.Name.Equals(datasetId)){
            Console.WriteLine("Deleting dataset named " + dataset.Name + " with ID of " + dataset.Name + "...");
            client.Datasets.DeleteDatasetByIdAsync(workspaceCollectionName, workspaceId, dataset.Id).Wait();
          }
        }
      }      
    }

If you want to see all the code I wrote to publish PBIX files to Power BI Embedded, you can check out this GITHUB repo and look at the program.cs file in the project named PBIEmbeddedDemo_Provisioning.

 

https://github.com/CriticalPathTraining/PowerBiEmbedded

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.