Test a policy with What If and the sign-in logs
In this task you'll check which Conditional Access policies apply to a sign-in.
Two tools tell you what a policy does before you switch it on. What If asks "if this user signed in to this app from here, which policies would apply?" without anyone signing in. The sign-in logs show what actually happened at each real sign-in, including what report-only policies would have done.
When someone says "I can't sign in", the sign-in logs are the first place to look: they name the policy that blocked them and why.
Example. After a week in Report-only, SS Kaiser's sign-in logs showed its MFA policy would have blocked a shared warehouse scanner account. The team excluded that account before switching the policy on.
Costs money. Uses the Report-only policy from the previous task, which needs Entra ID P1 (or a trial). Reading logs and running What If cost nothing more.
Before you start
You need: Security Reader or Reports Reader, and a policy from the previous task. Time: 15 minutes.
Where to look
- entra.microsoft.com
- Entra ID
- Conditional Access
- Policies
- What If
Steps
- Open Conditional Access, then Policies, and select What If.
- Pick your test user and set Target resources to any app, then select What If.The results list Policies that will apply and Policies that will not apply, with the reason for each.
- Find CA001 in the list and read its state and grant controls.Report-only policies are listed too, so you can test before switching on.
- Open Entra ID, then Monitoring & health, then Sign-in logs, and find the test user's sign-in from the last task.Logs can take a few minutes to appear.
- Select the sign-in and open the Report-only tab.It shows each report-only policy and whether it would have succeeded, failed or not applied.
- Open the Conditional Access tab too.This shows policies that are On. With only a report-only policy, it says none were applied.
Commands
# The test user's last few sign-ins and their Conditional Access result (needs AuditLog.Read.All)
az rest --method get \
--url "https://graph.microsoft.com/v1.0/auditLogs/signIns?\$top=5" \
--query "value[].{user:userPrincipalName, app:appDisplayName, ca:conditionalAccessStatus}" --output table
Watch out for
- Cost
- Free once you have the P1 licence or trial. Sign-in logs are kept for 30 days with P1.
- Security
- Sign-in logs hold personal data such as IP addresses and locations, so only give log access to people who need it.
- Common mistakes
- Testing What If against the wrong app or a user outside the policy, and deciding the policy is broken. Reading the Conditional Access tab and missing the Report-only tab.
Clean up
- Entra ID
- Conditional Access
- Policies
- CA001: Require MFA for pilot users
- Delete
Nothing new was made here. Delete the CA001 policy, the ca-pilot group and the test user when you've finished both tasks.
Words to know
- What If
- A tool that predicts which policies apply to a sign-in you describe.
- Sign-in logs
- A record of every sign-in, with the result of each Conditional Access policy.
- Report-only (Failure)
- What a report-only policy logs when it would have blocked or challenged the user.
Tick off each step and track your progress in the guide.
Open this task in Azure Portal, Hands On