-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve performance of Defender query to count users without advanced auditing #1406
improve performance of Defender query to count users without advanced auditing #1406
Conversation
Testing Instructions for ReviewersThe goals of testing this PR are to ensure:
Install dependenciesInstall the Powershell profiler module. Take measurements using the main branch (status quo)
Take measurements using the fix branch (associated with this PR)
Validate that the fix works as expected
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code updates look good and work as expected to retrieve just the count and a single record which decreases the memory footprint for the provider and improves overall performance.
Ran tests against each of the test tenants and all reported the expected results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested profiler in 2 tenants and found that code improved runtime.
@nanda-katikaneni ready for merge |
🗣 Description
This PR fixes a bug in Defender that is observed in larger tenants. Defender runs a query via Get-MgBetaUser to get a count of users that do not have the advanced auditing feature assigned to them. Instead of just retrieving the count from the REST API, the current query downloads all the users that match the filter. If a tenant has thousands of users without advanced audit this can result in significant slowness. I added the Top = 1 parameter so that only a single record is returned and verified that the count still works. See the linked issue below for full details and screenshots.
Closes #1404
🧪 Testing
See the screenshots in the linked issue above for details on the before and after testing that I performed with the fix against a tenant with over 2,000 users.
✅ Pre-approval checklist
✅ Pre-merge checklist
PR passed smoke test check.
Feature branch has been rebased against changes from parent branch, as needed
Use
Rebase branch
button below or use this reference to rebase from the command line.Resolved all merge conflicts on branch
Notified merge coordinator that PR is ready for merge via comment mention
✅ Post-merge checklist