
The Power of Azure AI Foundry
- June 16th, 2025
- 560 Views
Good news: You can easily leverage the Microsoft Graph API + Power Query (M Language) to read Purview metadata!
PurviewGraphReader
https://localhost
(for testing)Catalog.Read.All
(needed for Purview Catalog API)https://your-account.purview.azure.com
)
let
// Parameters - replace with your values
tenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
clientSecret = "YOUR_CLIENT_SECRET",
purviewAccountName = "your-purview-account",
// Get Token URL
tokenUrl = "https://login.microsoftonline.com/" & tenantId & "/oauth2/v2.0/token",
// Request Access Token
tokenResponse = Json.Document(Web.Contents(tokenUrl,
[
Content = Text.ToBinary("client_id=" & clientId &
"&scope=https%3A%2F%2Fpurview.azure.net%2F.default" &
"&client_secret=" & clientSecret &
"&grant_type=client_credentials"),
Headers = [#"Content-Type"="application/x-www-form-urlencoded"]
])),
access_token = tokenResponse[access_token],
// Call Purview Catalog API
purviewUrl = "https://" & purviewAccountName & ".purview.azure.com/catalog/api/search/query?api-version=2021-05-01-preview",
// Example Body - Adjust for your use case
body = "{""keywords"":""*""}",
purviewResponse = Json.Document(Web.Contents(purviewUrl,
[
Headers = [
#"Authorization" = "Bearer " & access_token,
#"Content-Type"="application/json"
],
Content=Text.ToBinary(body),
Method="POST"
])),
// Convert API response to a table
purviewData = purviewResponse[results],
purviewTable = Table.FromList(purviewData, Splitter.SplitByNothing(), {"Record"})
in
purviewTable
You can now easily load this data inside:
Catalog.Read.All
permission is read-onlyError | Reason |
---|---|
Invalid client secret | Check if the client secret expired or is wrong |
Insufficient privileges | Make sure you granted admin consent |
401 Unauthorized | Wrong tenant ID, client ID, or missing scope |
body
parameter for custom searches