Microsoft 365 outage: still ongoing. Microsoft reports recovery completed for parts of Asia Pacific, with mailbox access and delayed email improving, and is extending fixes to other regions. Next update by 12:00 UK time. Latest status
azureblog.co.uk
← cd ~/tools
// tools/role-right-sizer

Role right-sizer

Load an Azure Activity log export, pick a user, app or managed identity, and get a custom role that holds only the actions it actually used. You'll see how much access it would lose, whether a built-in role already fits, and the commands to make the swap.

Runs entirely in your browser. Nothing you paste is sent anywhere.

Not sure how to get it? See get the log below. The sample is made up: contoso.com and every name in it are fictional.

Get the log

Export everything one identity changed in the last 90 days. Run it once for each subscription it works in, or combine the files. The command returns only 50 events unless you raise --max-events.

shell4 lines
az monitor activity-log list \
  --subscription "<subscription name or ID>" \
  --caller "<UPN, or the identity's ID as it appears in the log>" \
  --offset 90d --max-events 10000 > activity.json

Leave out --caller to export everyone, then pick the identity here. If you send the activity log to a Log Analytics workspace, you can look back further than 90 days. Run this and export the results as CSV:

kql4 lines
AzureActivity
| where TimeGenerated > ago(180d)
| where CategoryValue == "Administrative"
| project TimeGenerated, Caller, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, _ResourceId, ResourceGroup, CorrelationId

What it can't see

Test the new role alongside the old assignment first, then remove the old one once nothing has failed for a while. Each tenant can have up to 5,000 custom roles.

How it works