Isolate risky Entra ID users
Last updated Oct 12, 2026 Microsoft Entra ID (formerly Azure Active Directory) calculates a user's risk level ↗︎ based on the probability that their account has been compromised. With Cloudflare Zero Trust, you can synchronize the Entra ID risky users list with Cloudflare Access and apply more stringent Zero Trust policies to users at higher risk.
This tutorial demonstrates how to automatically redirect users to a remote browser when they are deemed risky by Entra ID.
Time to complete:
1 hour
Prerequisites
- Microsoft Entra ID Premium P2 license
- Cloudflare Browser Isolation add-on
- Gateway HTTP filtering enabled on your devices
- npm ↗︎ installation
- Node.js ↗︎ installation
1. Set up Entra ID as an identity provider
Refer to our IdP setup instructions for Entra ID.
Note
- When you configure the IdP in Cloudflare One, be sure to select Enable group membership change reauthentication.
- Save the Application (client) ID, Directory (tenant) ID, and Client secret as you will need them again in a later step.
2. Add Entra ID API permissions
Once the base IdP integration is tested and working, enable additional permissions that will allow a script to create and update risky user groups in Entra ID:
- In Microsoft Entra ID, go to App registrations.
- Select the application you created for the IdP integration.
- Go to API permissions and select Add a permission.
- Select Microsoft Graph.
- Select Application permissions and add the following permissions ↗︎:
IdentityRiskyUser.ReadAllDirectory.ReadWriteAllGroup.CreateGroup.ReadAllGroupMember.ReadAllGroupMember.ReadWriteAll- Select Grant admin consent.
You will see the list of enabled permissions.

3. Add risky users to Entra ID group
Next, configure an automated script that will populate an Entra ID security group with risky users.
To get started quickly, deploy our example Cloudflare Workers script by following the step-by-step instructions below. Alternatively, you can implement the script using Azure Functions ↗︎ or any other tool.
- Open a terminal and clone our example project.
sh
npm create cloudflare@latest risky-users -- --template https://github.com/cloudflare/msft-risky-user-ad-sync
- Go to the project directory.
sh
cd risky-users
- Modify the Wrangler configuration file to include the following values:
<ACCOUNT_ID>: your Cloudflare account ID.<TENANT_ID>: your Entra ID Directory (tenant) ID, obtained when setting up Entra ID as an identity provider.<CLIENT_ID>: your Entra ID Application (client) ID, obtained when setting up Entra ID as an identity provider.
jsonc
{
"$schema": "./node_modules/wrangler/config-schema.json",
"name": "risky-users",
// Set this to today's date
"compatibility_date": "2026-10-27",
"main": "src/index.js",
"upload_source_maps": true,
"workers_dev": false,
"account_id": "<ACCOUNT-ID>",
"vars": {
"AZURE_AD_TENANT_ID": "<TENANT-ID>",
"AZURE_AD_CLIENT_ID": "<CLIENT-ID>",
},
"triggers": {
"crons": ["* * * * *"],
},
}
```toml
"$schema" = "./node_modules/wrangler/config-schema.json"
name = "risky-users"
# Set this to today's date
compatibility_date = "2026-10-27"
main = "src/index.js"
upload_source_maps = true
workers_dev = false
account_id = "
[vars]
AZURE_AD_TENANT_ID = "
[triggers] crons = [ " * * * " ] ```
Note
The Cron Trigger in this example schedules the script to run every minute. Learn more about supported cron expressions.
- Deploy the Worker to Cloudflare's global network.
sh
npx wrangler deploy
- Create a secret variable named
AZURE_AD_CLIENT_SECRET.
sh
wrangler secret put AZURE_AD_CLIENT_SECRET
You will be prompted to input the secret's value. Enter the Client secret obtained when setting up Microsoft Entra ID as an identity provider.
The Worker script will begin executing once per minute. To view realtime logs, run the following command and wait for the script to execute:
wrangler tail --format pretty
After the initial run, the auto-generated groups will appear in the Entra ID dashboard.

4. Synchronize risky user groups
Next, synchronize Entra ID risky user groups with Cloudflare Access:
- Enable SCIM synchronization.
- In Entra ID, assign the following groups to your SCIM enterprise application:
IdentityProtection-RiskyUser-RiskLevel-highIdentityProtection-RiskyUser-RiskLevel-mediumIdentityProtection-RiskyUser-RiskLevel-low
Cloudflare Access will now synchronize changes in group membership with Entra ID. You can verify the synchronization status on the SCIM application's Provisioning page.
5. Create a browser isolation policy
Finally, create a Gateway HTTP policy to isolate traffic for risky user groups.
- In Cloudflare One ↗︎, go to Traffic policies > Firewall policies > HTTP.
- Select Add a policy.
- Build an Isolate policy that contains a User Group Names rule. For example, the following policy serves
app1.example.comandapp2.example.comin a remote browser for all members flagged as high risk:
| Selector | Operator | Value | Logic | Action |
|---|---|---|---|---|
| Domain | in | app1.example.com, app2.example.com |
And | Isolate |
| User Group Names | in | IdentityProtection-RiskyUser-RiskLevel-high |
To test the policy, refer to the Microsoft documentation for simulating risky detections ↗︎.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/cloudflare-one/tutorials/entra-id-risky-users/#page","headline":"Isolate risky Entra ID users","description":"Microsoft Entra ID (formerly Azure Active Directory) calculates a user's risk level based on the probability that their account has been compromised. With Cloudflare Zero Trust, you can synchronize the Entra ID risky users list with Cloudflare Access and apply more stringent Zero Trust policies to users at higher risk.","url":"https://developers.cloudflare.com/cloudflare-one/tutorials/entra-id-risky-users/","inLanguage":"en","image":"https://developers.cloudflare.com/cloudflare-one/tutorials/entra-id-risky-users/og.png?v=369f02318800a6b5","dateModified":"2026-10-12","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["Microsoft Entra ID","SCIM"]}
description: You can build Zero Trust rules to secure connections to MongoDB deployments using Cloudflare Access and Cloudflared Tunnel. title: MongoDB SSH image: https://developers.cloudflare.com/cloudflare-one/tutorials/mongodb-tunnel/og.png?v=b8e4a862129a0658
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/cloudflare-one/llms.txt
Use this file to discover all available pages before exploring further.
