Forum Discussion
How to access Defender for Cloud Apps data and store it for long-term Power BI analysis?
- 1 year ago
Hi gulce,
Thank you for reaching out to Microsoft Fabric Community.
Thank you johnbasha33 for the prompt response.
The API is not returning all the apps or users you see in the defender because,
- The API call without a streamId only returns data for one stream, that is why there are only few records. And full pagination is not implemented, here the API returns results in pages so by default it may be showing only the first page records.
Please follow below steps:
- Get all stream IDs from /api/discovery/streams/
- For each streamId, call /api/v1/discovery/discovered_apps with that streamId in the request body.
- Implement pagination by checking hasNext and use the nextQueryFilters until no more pages remain.
- Combine results from all the streams to match the portal’s total count.
This will return all records from all reports, matching what you see in the portal.
Thanks and regards,
Anjan Kumar Chippa
Hi v-achippa
Thanks a lot for the detailed pointers.
We tried both pagination patterns you suggested on /api/v1/discovery/app_users, but we’re still stuck:
What we did
We have 2 streamIds. One returns “no data”. The other returns total: 101 and "hasNext": false on the very first call.
Request #1 (first page):
POST /api/v1/discovery/app_users
{
"filters": {},
"streamId": "<streamId>",
"appId": 11394,
"timeframe": 90,
"sortField": "trafficTotalBytes",
"sortDirection": "desc",
"limit": 100
}
Response (excerpt):
{
"results": [ ... 101 items ... ],
"total": 101,
"hasNext": false
}
So there’s no nextQueryFilters returned, and hasNext is already false on page 1.
What we tried next
1.Putting only the nextQueryFilters keys inside filters (as recommended).
When we attempt a second call with:
{
"filters": { "skip": 101, "page": 2 },
"streamId": "<streamId>",
"appId": 11394,
"timeframe": 90,
"sortField": "trafficTotalBytes",
"sortDirection": "desc",
"limit": 100
}
…we get:
"detail": "Invalid filter params were sent to API: {'skip': 101, 'page': 2}"
2.Nesting nextQueryFilters inside filters (alternative shape):
{
"filters": {
"nextQueryFilters": { "skip": 101, "page": 2 }
},
"streamId": "<streamId>",
"appId": 11394,
"timeframe": 90,
"sortField": "trafficTotalBytes",
"sortDirection": "desc",
"limit": 100
}
This also fails with a similar “Invalid filter params” error.
Because of the above, the REST path isn’t letting us advance beyond the first 101 users.
Questions on REST
Could you confirm the exact expected JSON shape for filters in app_users pagination?
– Should filters contain only the returned nextQueryFilters keys (e.g., skip, page), without any other fields?
– Or should we nest them as { "filters": { "nextQueryFilters": { ... } } }?
– Is there a chance page isn’t supported in our tenant and we must send only skip?
Given our first-page response already has "hasNext": false, is it expected that some apps/streams truly have only 101 users? (If so, that would explain things; just want to double-check.)
Graph API path (works) & follow-ups
In Graph Explorer we can list users for the app via (example):
GET /beta/security/dataDiscovery/cloudAppDiscovery/uploadedStreams/{streamId}/aggregatedAppsDetails(period=duration'P90D')/{appId}/users?$skip=300
This returns the next page of users correctly.
What we still need is guidance on other fields beyond the user list:
Which Graph endpoints/properties expose the aggregated metrics we see in MCAS (e.g., trafficTotalBytes, trafficUploadedBytes, lastSeen, etc.) per app and/or per user?
– Is it via the {appId} resource of aggregatedAppsDetails(...) with $select?
– Is there a way to get per-user traffic totals via Graph, or only app-level aggregates?
Any recommendations on pagination best practices here: should we prefer $top + @odata.nextLink over $skip, or is $skip the intended approach for these endpoints?
Which permissions/scopes do you recommend for production (delegated/app)? (e.g., which exact Security/Cloud App Discovery scopes are required.)
Finally, is there a v1.0 equivalent for these endpoints, or is /beta currently the only available surface?
Thanks again for your help—any sample queries/snippets showing how to pull users + their traffic metrics for a given {streamId, appId, period} would be greatly appreciated.
Hi gulce,
Thank you for the detailed response. Since you are consistently seeing hasNext:false at 101 rows even when more users exist, I recommend you to please raise a Microsoft support ticket with all the details, so the product team can review the backend logs for your tenant and confirm whether it is a limitation or a tenant specific issue.
To raise a support ticket, kindly follow the steps outlined in the following guide:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
Thanks and regards,
Anjan Kumar Chippa