Skip to content

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:

grep AZURE_CLIENT_ID /root/netbox-docker/env/netbox.env

Steps

1. Create a new secret in Entra

  1. Open App registrations → All applications and find the app whose Application (client) ID matches AZURE_CLIENT_ID.
  2. Go to Certificates & secrets → Client secrets → New client secret.
  3. Add a description (e.g. NetBox 2027) and choose an expiry.
  4. Copy the Value immediately. It's only shown once. Do not use the Secret ID.

2. Update NetBox

On the server:

nano /root/netbox-docker/env/netbox.env

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.

cd /root/netbox-docker
docker compose up -d --force-recreate netbox netbox-worker

4. Verify

docker compose ps                     # netbox should show (healthy)
docker compose logs --tail=50 netbox  # no errors

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.