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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
nelsonnyland
Regular Visitor

Power BI SDK for .NET: Service Code Retry Handling

I have a .NET 8 app connecting to Power BI API using the provided SDK nuget package (Microsoft.PowerBI.Api). 

 

Is there a provided retry handler for bad service codes?

 

Thank you.

1 ACCEPTED SOLUTION

Thank you for the follow-up, you're absolutely right to clarify that Microsoft.PowerBI.Api is not part of the .NET Graph SDK or a NuGet server API.The Power BI .NET SDK (Microsoft.PowerBI.Api) does not have built-in retry logic.

Unlike the Graph SDK, which includes a built-in retry handler for throttling (like 429s or 5xx errors), the Power BI SDK is a more lightweight wrapper over the REST API. That means you’ll need to implement your own retry mechanism if you want to handle transient faults or throttling scenarios.

A common approach is to use a library like Polly to define a retry policy. Here’s an example of how that might look in C#:

 

var retryPolicy = Policy
    .Handle<HttpRequestException>()
    .OrResult<HttpResponseMessage>(r =>
        (int)r.StatusCode == 429 || (int)r.StatusCode >= 500)
    .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));

var result = await retryPolicy.ExecuteAsync(() =>
    powerBIClient.Reports.GetReportInGroupAsync(groupId, reportId));

 

ConnectionPolicy.RetryOptions Property (Microsoft.Azure.Documents.Client) - Azure for .NET Developer...

Implement a retry policy using the Azure Storage client library for .NET - Azure Storage | Microsoft...

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!

 

Regards,

B Manikanteswara Reddy

View solution in original post

4 REPLIES 4
v-bmanikante
Community Support
Community Support

Hi @nelsonnyland ,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

 

Any GET request made to a API endpoint may return an HTTP redirect (301 or 302). Clients should gracefully handle such redirects by observing the Location header and issuing a subsequent GET. Documentation concerning specific endpoints will not explicitly call out where redirects may be used.

In the case of a 500-level status code, the client can implement a reasonable retry mechanism. The official NuGet client retries three times when encountering any 500-level status code or TCP/DNS error.

 

Please refer the below documents for better understanding.
Overview of the NuGet Server API | Microsoft Learn
NuGet.org Frequently-Asked Questions | Microsoft Learn

.NET Graph SDK v5 RetryHandler question - Microsoft Q&A

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!

 

Regards,

B Manikanteswara Reddy

Hi Manikanteswara,

 

It looks like there is some misunderstanding. I am looking for information regarding (Microsoft.PowerBI.Api). This is not a .NET Graph SDK, and as far as I know this is not a NuGet Server API. I have not been able to find any documentation specifically about the Power BI SDK that states whether it has a retry mechanism. Given that the .NET Graph SDK comes with retry handling, I would not be surprised if that was indeed the case. 

 

Regards,

 

Nelson Nyland

Thank you for the follow-up, you're absolutely right to clarify that Microsoft.PowerBI.Api is not part of the .NET Graph SDK or a NuGet server API.The Power BI .NET SDK (Microsoft.PowerBI.Api) does not have built-in retry logic.

Unlike the Graph SDK, which includes a built-in retry handler for throttling (like 429s or 5xx errors), the Power BI SDK is a more lightweight wrapper over the REST API. That means you’ll need to implement your own retry mechanism if you want to handle transient faults or throttling scenarios.

A common approach is to use a library like Polly to define a retry policy. Here’s an example of how that might look in C#:

 

var retryPolicy = Policy
    .Handle<HttpRequestException>()
    .OrResult<HttpResponseMessage>(r =>
        (int)r.StatusCode == 429 || (int)r.StatusCode >= 500)
    .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));

var result = await retryPolicy.ExecuteAsync(() =>
    powerBIClient.Reports.GetReportInGroupAsync(groupId, reportId));

 

ConnectionPolicy.RetryOptions Property (Microsoft.Azure.Documents.Client) - Azure for .NET Developer...

Implement a retry policy using the Azure Storage client library for .NET - Azure Storage | Microsoft...

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!

 

Regards,

B Manikanteswara Reddy

Hi @nelsonnyland ,

 

We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Please don't forget to give a "Kudos vbmanikante_0-1748259022250.png" – I’d truly appreciate it!

 

Regards,

B Manikanteswara Reddy

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.