NetBox – Rotating the Entra ID Client Secret
NetBox web logins via Microsoft Entra ID use a client secret from the Entra app registration. Client secrets expire. When it expires, SSO logins fail with AADSTS7000222 (expired secret) or AADSTS7000215 (invalid secret). Local NetBox logins keep working.
Rotate the secret before the expiry date.
Where the secret lives
| Environment | Server | File | Variable |
|---|---|---|---|
Production (https://netbox.iohub.cloud) |
jnb1srvdscocsprxvm196-ip-manager-netbox |
/root/netbox-docker/env/netbox.env |
AZURE_CLIENT_SECRET |
UAT (http://localhost:8000 via SSH tunnel) |
jnb1srvdscocsprxvm194-ip-manager-netboxuat |
/root/netbox-docker/env/netbox.env |
AZURE_CLIENT_SECRET |
The secret is created in the Entra admin center → App registrations → (NetBox app) → Certificates & secrets.
Each server's AZURE_CLIENT_ID tells you which app registration it uses:
Steps
1. Create a new secret in Entra
- Open App registrations → All applications and find the app whose Application (client) ID matches
AZURE_CLIENT_ID. - Go to Certificates & secrets → Client secrets → New client secret.
- Add a description (e.g.
NetBox 2027) and choose an expiry. - Copy the Value immediately. It's only shown once. Do not use the Secret ID.
2. Update NetBox
On the server:
Replace the value of AZURE_CLIENT_SECRET= with the new secret value, and save.
3. Recreate the containers
A plain restart does not reload environment variables.
4. Verify
Then test a Microsoft login in a private browser window.
5. Clean up
Once logins work, delete the old secret in Entra under Certificates & secrets, and set a calendar reminder about two weeks before the new expiry date.
If UAT and Production share one app registration
A new secret in that app works for both. Update AZURE_CLIENT_SECRET on both servers before deleting the old secret.
Rollback
If the new secret doesn't work and the old one hasn't expired yet, put the old value back in netbox.env and repeat step 3. The local admin account always works as a fallback.