Defender Advanced Hunting API to Microsoft Graph Migration Kit
Microsoft is retiring the Microsoft Defender for Endpoint and Defender XDR Advanced Hunting APIs. They stop returning data on 1 February 2027, and Microsoft asks customers to move every workflow to the Microsoft Graph security API by 31 January 2027. There is no automatic migration.
Your KQL queries carry over. Everything around them changes: the URL, the token resource, the app permissions, the response casing (Schema/Results become schema/results), and Stats disappears. Python and JavaScript code that reads data["Results"] breaks.
What's inside:
- hunt_scan.py: a read-only scanner that finds old hunting endpoints (including regional hosts), old permissions, old token resources next to them, and PascalCase response reads in Python, JS/TS, C#, Java and Go. Ignores the MDE APIs that aren't retiring (machines, alerts). Text or JSON output, CI exit codes. Never prints line contents, so secrets stay out of logs.
- - hunting_adapter.py (Python 3.9+, standard library only): run_hunting_query() calls Graph and returns the old Schema/Results shape with the original column casing, so data["Results"] keeps working. Retries 429/503 using Retry-After, masks tokens in errors, validates Timespan, includes a client-credentials token helper and a CLI.
- - MIGRATION-GUIDE.md: app registration and admin consent, managed identities, before/after code for requests, msal, PowerShell Invoke-RestMethod and Start-MgSecurityHuntingQuery, Logic Apps and Sentinel playbooks, Power Platform, Timespan, a limits table for old vs new, and a test plan.
- - CHECKLIST.md and 21 tests.
Who it's for: SOC engineers, detection engineers and MSSPs with scripts, playbooks or tools on the old Advanced Hunting APIs.
Honest limits: Graph returns no Stats, so code that reads it must change. US Government and other national clouds use different hosts and aren't supported by the adapter as shipped. Check Microsoft's current docs before going live.
Independent product. Not affiliated with Microsoft.