Microsoft Graph contains an enormous amount of information that might be useful to show in a Power BI report. Up until May 31st, 2018 this was possible out of the box, but it stopped working (issue report).
This solution is a temporary workaround until Microsoft fixes the issue or releases a dedicated Microsoft Graph connector for Power BI.
The code is an Azure Function that accepts any get request and passes the request on to the Microsoft Graph. Upon receiving the result, some transformation is done to make sure subsequent requests (eg. paging) get send through the Azure Function (instead of directly to the Microsoft Graph).
GET https://{function-app-name}.azurewebsites.net/v1.0/users
GET https://{function-app-name}.azurewebsites.net/v1.0/users?$select=id,displayName
GET https://{function-app-name}.azurewebsites.net/beta/teams/{teamId}
Detailed explanation coming soon in a blogpost on https://yannick.reekmans.be
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
- Create an Azure Function App in the Azure Portal
- Clone the repository
- Deploy the code into the newly created Azure Function App
- In the Azure Portal, open the Function App
- Open Platform Features
- Open Managed service identity
- Register with Azure Active Directory: 'On'
- Save
- Open Authentication / Authorization
- App Service Authentication: 'On'
- Action to take when request is not authenticated: 'Log in with Azure Active Directory'
- Azure Active Directory:
- Management mode: 'Express'
- Management mode: 'Create New AD App'
- Create App: 'Microsoft Graph Proxy Function'
- Grant Common Data Services Permissions: 'Off'
- Save and close the blades
- Open Authentication / Authorization
- Azure Active Directory
- Management mode: 'Advanced'
- Copy and store the values for:
- Client Id
- Client Secret
- Allowed token audiences
- Copy the existing url
- Add it again, without '/.auth/login/aad/callback' (make sure there is no more ending /)
- Save
- Azure Active Directory
- In the Azure Portal, create a KeyVault
- While creating
- Open Access policies
- Add new
- Select principal: 'Name of your Function App'
- Secrets permissions: 'Get'
- Close blades, click Create
- Open the new Azure Key Vault
- Copy and store the url for later
- Secrets
- Click Generate/Import
- Upload options: 'Manual'
- Name: 'ClientSecret'
- Value: 'the secret from the Azure AD Application step'
- Content type: 'leave empty'
- Set activation date? 'Unchecked'
- Set expiration date? 'Unchecked'
- Enabled? 'Yes'
- Click Create
- While creating
- In the Azure Portal, open the Azure Function App
- Open Platform features
- Open Application settings, add the following keys with values:
- Authority: 'https://login.microsoftonline.com'
- ClientId: 'Client Id previously copied'
- ClientSecretName: 'ClientSecret'
- GraphBaseUrl: 'https://graph.microsoft.com'
- KeyVaultUri: 'Url copied from the Azure Key Vault'
- TenantId: 'id of your Azure AD tenant'
- UseApplicationPermissions: 'true or false'
- In the Azure Portal, open Azure Active Directory
- Open App registrations, and find Microsoft Graph Proxy Function in the list
- Open the Settings and go into Permissions
- Add Microsoft Graph as API and select the required permissions.
- Application Permissions when UseApplicationPermissions is true, and you want the Azure Function to connect to the Microsoft Graph
- Delegated Permissions when UseApplicationPermissions is set to false, and you want to access the Microsoft Graph on behalf of the logged in user
- Add a data source, select OData.
- Enter the url of the Azure Function and append the Microsoft Graph query
- When asked for authentication, select Organizational Account and enter the credentials of a user account.
- Access reports as JSON from the /beta endpoint results in a parsing issue in Power BI. Since the function is just passing through information, this issue is probably caused by Microsoft Graph or Power BI
- Accessing large datasets might result in a
429 Too Many Requests
response. Power BI doesn't handle this gracefully and just errors out.