How to back up Conditional Access policies
Published
Conditional Access decides who can sign in, from where and with what. One wrong edit can lock out a whole organization, and the admin center keeps no copy of how a policy looked last week.
What Microsoft gives you
The Entra admin center can restore a policy that was deleted recently. That helps with a deletion and with nothing else: a policy that was changed has no earlier version to go back to. The audit log records that a change happened and who made it, but it is not a copy you can restore from, and it is kept for a limited time.
So the copy has to be made by you, before the day you need it.
Export the policies with Microsoft Graph PowerShell
Conditional Access policies are read from Microsoft Graph at /identity/conditionalAccess/policies. Reading them needs the permission Policy.Read.All. With the Microsoft Graph PowerShell module installed:
Connect-MgGraph -Scopes "Policy.Read.All"
Get-MgIdentityConditionalAccessPolicy -All | ForEach-Object {
$_ | ConvertTo-Json -Depth 10 | Out-File "CA-$($_.Id).json"
}
That writes one JSON file per policy. Keep the files somewhere that does not depend on the tenant they describe, and run the export again after every change, or on a schedule.
What the export leaves out
A Conditional Access policy is mostly references. The JSON names other objects by id, and those objects are not in the file:
- Named locations. A policy that blocks sign-ins from outside your trusted countries holds only the id of the location. Export them too:
Get-MgIdentityConditionalAccessNamedLocation -All. - Authentication strengths. Custom strengths are separate objects. If one is deleted and recreated it gets a new id, and every policy that named the old one has to be pointed at the new one.
- Users, groups and roles. Included and excluded groups are ids. If the group with your break-glass accounts is deleted, the exclusion in the file points at nothing.
- Applications, terms of use and authentication contexts. Also ids, also kept elsewhere.
An export of the policies alone is therefore a record, not yet a backup. To restore from it you need the objects it refers to, or you need to know what each id used to be.
Putting a policy back by hand
Changing a policy needs Policy.ReadWrite.ConditionalAccess. Three rules keep a restore from making things worse:
- Recreate in report-only. Set
statetoenabledForReportingButNotEnforcedbefore you create the policy, look at its effect in the sign-in logs, and only then switch it on. - Remove what Microsoft fills in. Take
id,createdDateTimeandmodifiedDateTimeout of the JSON before you send it. - Check every reference first. A policy that names a group or a location that no longer exists is refused, or worse, applies to more people than it used to.
What GlacierPoint Snapshot does
It makes the same copy, with the pieces that belong together:
- Conditional Access policies, named locations, custom authentication strengths, authentication contexts and terms of use are backed up together, on demand or on a schedule.
- Compare shows a policy as it was beside the policy as it is, setting by setting, so you see what changed before you decide anything.
- A restore shows a preview first and writes nothing until you confirm. A policy that no longer exists comes back in report-only unless you choose otherwise.
- Every restored item is recorded in a journal on your computer, and the restore can be rolled back from it.
- Nothing is ever deleted: a policy that exists in the tenant but not in the backup is reported and left alone.
The app runs on your computer and signs in as you. We hold no access to your tenant; the permissions page lists every permission by name.
Conditional Access is one of 484 configuration types. See what else is backed up.