3
votes

Dears, I am showing PBI Reports based on filter criteria selected by user. In order to show the reports, I am using Microsoft Power BI API in C#. It was working fine but suddenly start giving me following error:

You have exceeded the amount of embed token that can be generated on a shared capacity. You need to purchase Azure capacities to generate embed tokens. See https://go.microsoft.com/fwlink/?linkid=868976\

using (var powerBiClient = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
{
   var reports = powerBiClient.Reports.GetReportsInGroupAsync(groupId).GetAwaiter().GetResult();
   var report = reports.Value.FirstOrDefault(rep => rep.Id == reportId);
   var datasets = powerBiClient.Datasets.GetDatasetByIdInGroupAsync(groupId, report.DatasetId).GetAwaiter().GetResult();
   var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
   var tokenResponse = powerBiClient.Reports.GenerateTokenInGroupAsync(groupId, report.Id, generateTokenRequestParameters).GetAwaiter().GetResult();
}

I am getting an error at last line (i.e. GenerateTokenInGroupAsync). In order to resolve the issue, it is recommended to get the PBI Pro License but it is not possible in my case. So could someone recommend me any other way to get my work done instead of Publishing to Web and get the Embedded URL because I need to filter the report based on user selection.

Can I access and show the reports without access token or get the token without Pro license?

1

1 Answers

4
votes

This is not about Pro license, but about Premium. You already have Pro, otherwise you wont be able to work with groups (workspaces), which is Pro only feature (it may was a trial only, though). However, GenerateTokenInGroup is something related to Premium capacities. Without capacity assigned to your workspace, you have a limited number of tokens, that you can generate. See Create a dedicated capacity:

Using embed tokens with PRO licenses are intended for development testing, so the number of embed tokens a Power BI master account or service principal can generate is limited. A dedicated capacity requires embedding in a production environment. There's no limit on how many embed tokens you can generate with a dedicated capacity.

So you went to production without assigning a dedicated capacity and you reached the limit of tokens that you can generate. You must either buy Power BI Premium capacity and assign it to this workspace (which will allow you to continue without changes in your code), or stop using embedded tokens at all.

You can use AAD tokens instead. In the embedConfiguration change tokenType to be TokenType.AAd and use the token you get from ADAL's AcquireTokenAsync method (the one you used to construct tokenCredentials passed to PowerBIClient's constructor).