Graph SDK - Reports.GetSharePointSiteUsageDetail not working in azure function due to missing token

Marek Kembrowski 0 Reputation points
2023-03-21T10:30:24.4733333+00:00

Hi,

Two days ago we have noticed that Azure Functions that are using Graph SDK 4.54 during call to Reports.GetSharePointSiteUsageDetail (and other report endpoints that returns streams) doesn't work for both beta and 1.0 endpoints. After investigation it appears that there is a problem with Azure Functions internals, as the same code works well on local dev machine and in xunit test project. All are using .NET 6.0, azure function .NET 6.0 Isolated.

The issues seems to be related to second request in the flow. First one:

Sending Graph : https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')  returns correct 302 response on dev machine and test project in azure devops. same for second response which is using request uri comming from Location header:

Sending Graph: https://reportsweu.office.com/data/v1.0/download?token=<someToken> 

now in azure, the second request doesn't have the query parameter which results in error:

tatus Code: ForbiddenMicrosoft.Graph.ServiceException: Code: MissingCredentialsMessage: Valid Authorization header

To be precise: the Location header looks totally different in azure function:

https://reportsweu.office.com/graph/v1.0/data/<tenantId>/Microsoft.O365Reporting.getSharePointSiteUsageDetail(period='D90')

Did anyone faced same problem

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,357 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.