RuiRomano / pbimonitor

MIT License
216 stars 79 forks source link

Power BI Monitoring - issues with Graph API #20

Closed dbhupla closed 1 year ago

dbhupla commented 2 years ago

Hi RuiRomano,

I've implemented the solution and managed to get most of it working, however I'm have issue retrieving Licence and User data from the Graph API.

Therefore the Licence and User tab has no data within the Power BI report.

Please could you help with this issue.. I believe it might be some kind of authorisation, as the rest of the report works

Any guidance will be much appreciated.

crcarley commented 2 years ago

@dbhupla try manually running the graphtimer function in the function app using the code area > test/run. This should run and populate the data to blob. Then refresh the report.

wolfgangstrasser commented 2 years ago

Hi @RuiRomano ,

we are facing the same problem - GraphTimer function returns with a 403 error

2022-09-14T08:50:09Z [Information] INFORMATION: Getting OAuth token 2022-09-14T08:50:09Z [Information] INFORMATION: Calling Graph API: 'https://graph.microsoft.com/beta/users?$select=id,displayName,assignedLicenses,UserPrincipalName' 2022-09-14T08:50:09Z [Information] INFORMATION: Ellapsed: 0.4134205s 2022-09-14T08:50:11Z [Information] OUTPUT: 2022-09-14T08:50:11Z [Information] OUTPUT: HistoryId: 1 2022-09-14T08:50:11Z [Information] OUTPUT: 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mMessage : [0mResponse status code does not indicate success: 403 (Forbidden). 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mStackTrace : [0m at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord) 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mException : [0mMicrosoft.PowerShell.Commands.HttpResponseException 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mInvocationInfo : [0m{Invoke-RestMethod} 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mLine : [0m $result = Invoke-RestMethod -Method Get -Uri $url -Headers $headers 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1m [0m 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mPosition : [0mAt C:\home\site\wwwroot\Scripts\Fetch - Graph.ps1:61 char:19 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1m [0m+ … $result = Invoke-RestMethod -Method Get -Uri $url -Headers $headers … 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1m [0m+ ~~~~~~~~~~~~~ 2022-09-14T08:50:11Z [Information] OUTPUT: [32;1mHistoryId : [0m1 2022-09-14T08:50:11Z [Information] OUTPUT: 2022-09-14T08:50:11Z [Error] EXCEPTION: Response status code does not indicate success: 403 (Forbidden).

RuiRomano commented 1 year ago

Please ensure you granted API Application level permissions on "Microsoft Graph" API with Administrator grant to get the license & user info data. I updated the docs with new screenshot.