Forum Discussion

JagadishNallami's avatar
JagadishNallami
Frequent Visitor
1 year ago
Solved

Task.Delay while polling export request in PowerBI is not completed after given interval

Hi there,

 

I am refering the following link to export a power bi report through PowerBi api using C#.

https://learn.microsoft.com/en-us/power-bi/developer/embedded/export-to#code-examples

 

But while polling the request, as mentioned in the link, we are also using await Task.Delay(retryafter), to reduce the frequency of requests for polling. But this Task is not completed within given interval(30 seconds in our case). Due to this the execution is blocked forever and we are not able to export the file. Is there any issue with code mentioned above? I tried using  await Task.Delay(retryafter).ConfigureAwait(false) also but no use.

 

Could someone help in understanding what is hapening in this case and possible solution? 

 

Thank you.

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi JagadishNallami 
    Thank you for reaching out microsoft fabric community forum.
    As lbendlin metioned ,the delay might be too short and increasing the delay duration might help.  instead of 30 seconds, try using a longer delay like 300 seconds (5 minutes).
    Using  ConfigureAwait(false) is a good practice to avoid deadlocks, but it might not be sufficient if the underlying issue is related to the export operation itself.
    Ensure that you are not hitting any API rate limits. If you are making frequent requests, the API might be throttling your requests, causing delays or failures

    If you need any further assistance or have any questions, please feel free to reach us.

    If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

    Thank you.

5 Replies

    • JagadishNallami's avatar
      JagadishNallami
      Frequent Visitor

      Hi, here the delay is the value we are receiving in the resposnse headers from the API. Like below

       

      var retryAfter = httpMessage.Response.Headers.RetryAfter;

      var retryAfterInSec = retryAfter.Delta.Value.Seconds;

      await Task.Delay(retryAfterInSec * 1000);

       

      You mean to ignore this and add a default timeout?

      • lbendlin's avatar
        lbendlin
        Super User

        Try both approaches. We always use 300 seconds and that seems to be robust.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JagadishNallami 
    Thank you for reaching out microsoft fabric community forum.
    As lbendlin metioned ,the delay might be too short and increasing the delay duration might help.  instead of 30 seconds, try using a longer delay like 300 seconds (5 minutes).
    Using  ConfigureAwait(false) is a good practice to avoid deadlocks, but it might not be sufficient if the underlying issue is related to the export operation itself.
    Ensure that you are not hitting any API rate limits. If you are making frequent requests, the API might be throttling your requests, causing delays or failures

    If you need any further assistance or have any questions, please feel free to reach us.

    If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JagadishNallami 

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

    Thank you