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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Timothy
New Member

Delete report and dataset from PowerBI workspace, same code, multiple tenants, different results

Hi all,

 

 

we have developed a service which can manage a PBIX file in a PowerBI Embedded Premium workspace in a Group using the official Microsoft V2 API. In order to prevent accidental overwrites based on the name, we delete the report (and the corresponding dataset) via the ID we received during the upload.

 

When deleting, we first delete the report, and then the corresponding dataset.

 

We do this with the following code:

 

var allReports = powerBiClient.Reports.GetReportsInGroup(groupId);
var oldReport = allReports.Value.FirstOrDefault(r => reportId.Equals(r.Id));
if (oldReport != null)
{
   powerBiClient.Reports.DeleteReportInGroup(groupId, oldReport.Id);
   powerBiClient.Datasets.DeleteDatasetByIdInGroup(groupId, oldReport.DatasetId);
}

 

 

Since we develop using DTAP environments we also have multiple Azure tenants. If we execute this code on our T(est) tenant, this works like a charm. If we execute this code on our P(roduction) tenant, this fails miserably.

 

The following line of code throws an "NotFound" HttpOperationException in our P tenant (and works perfect in our T tenant):

powerBiClient.Reports.DeleteReportInGroup(groupId, oldReport.Id);

I created a console app for easy debugging purposes, and we can see the report + dataset in the Power BI portal (app.powerbi.com) in the correct group and with the correct ID. When I debug, following in this line we get the HttpOperationException with the aforementioned "NotFound" message. While in the mean time, the report does get deleted succesfully, but leaving the dataset untouched.

 

If I remove this line, and only execute the DeleteDatasetByIdInGroup code, both the report and dataset get deleted in both the T and the P tenants.

 

The code is exactly the same in both situations, and in all situations the user used is a PowerBI capacity administrator and has admin rights on the workspace. And since the removal ultimately succeeds, it should not be an issue regarding permissions.

 

For full disclosure, I am using the Microsoft.PowerBI.Api nuget package V2.0.10 in our service and console application.

I did notice however, when granting permissions to the Azure AD App Registration used to access PowerBI, that in our T tenant it is listed as "Power BI Service (Power BI)", while in the P tenant it is listed as "Power BI Service (Microsoft.Azure.AnalysisServices)"

 

So the main question is, have I found a bug in Microsoft code? Did I miss some silly configuration? Am I doing something totally wrong? What could possibly be different between both tenants,?

 

Because to me everything appears to be configured identical, with the single difference being the Power BI Service in the app registration, and if so this indicates a bug in Microsoft code.

 

 Thanks for helping

0 REPLIES 0

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors