Azure App Secret Rotation
Automatically rotate the secret of an Azure app using Keeper Secrets Manager rotations
Last updated
Was this helpful?
Automatically rotate the secret of an Azure app using Keeper Secrets Manager rotations
Last updated
Was this helpful?
This documentation explains how to rotate Azure application secrets using KeeperPAM's rotation option called "Run PAM scripts only". This is a setting in the PAM User rotation settings which tells the Gateway to skip the primary rotation method and directly execute the post-rotation script attached to the PAM User record in the vault.
This guide includes prerequisites, step-by-step instructions, and a Python script example. The script ensures secure application secrets rotation, including deletion of previous application secrets, and stores the new application secret in Keeper. This new secret is automatically available to all already allowed KSM applications and users.
See the for a high level overview and getting started with Azure
This guide assumes the following tasks have already taken place:
are configured for your role
A Keeper Secrets Manager has been created
Your Azure environment is per our documentation
The gateway host will need to have a supported Python version installed with the 2 dependencies below:
The script retrieve admin credentials in three ways:
Record directly attached to the post rotation script.
The access key provided to the Azure PAM config selected for the rotation. This will be used if no access key is found in the record(s) attached (method 1 above) to the post rotation script.
The script will:
Retrieve an admin application secret either from an attached record to the PAM Script or from the PAM Config.
Get a Microsoft Graph access token using the admin application secret found at the step above.
Create a new client secret on the Azure application defined in the PAM User record.
Delete all other existing secrets for the defined Azure application. Only the one generated at the step above will be kept.
Update the Keeper PAM User record with the new secret, and secret ID.
Login
This mandatory field is not used in this script. You can use the field to store any useful information, like the name of the Azure app that will be rotated.
Password
It will be a dummy value in this case. The password field gets automatically rotated, but it is not used anywhere. This is still required field.
Text
This field is used to specify which application in Azure you want to rotate. You need to retrieve the application object ID of the application to rotate from the Azure portal > App Registration > Overview tab of your app > Application (client) ID.
Text
This field will receive the new client secret ID after the rotation.
Hidden Field
This field will receive the new client secret after the rotation.
Text
This field will receive the expiration date of the new secret after the rotation.
Text
Second field to enable NOOP.
The value has to be:
The script require an admin application secret to authenticate against Azure and rotate another application's secret. Here we will be using the admin app secret provided in the Azure PAM Configuration.
Create a shared folder in the vault
In the Secret Manager tab of the Keeper vault, create a new application for the gateway if there is no gateway yet.
Make sure the Application has edit permissions on the shared folder created above.
In the Secret Manager tab of the Keeper vault, go to the PAM Configurations tab. Create a new PAM configuration if needed.
Under Environment, please select “Azure”, select the Gateway, select the shared folder, provide the “Entra ID” name (arbitrary name of your Entra ID environment), the admin application “Client ID” (Overview tab of the admin application in the Azure portal), “Client Secret” (Certificates & secrets tab of the admin application in the Azure portal), "Subscription ID" and "Tenant ID".
Password Rotation Settings: select your desired schedule and the PAM configuration created above.
Select "Run PAM Scripts only" as the Rotation method.
Add PAM Script to the record: select the provided file below and make sure to specify the script command:
You need to create a record where the rotation will be configured later on. The fields below need to be created.
Create a PAM User record in the shared folder with the fields and custom fields described .
Provision the gateway (gateway tab after selecting the application) on a Linux box. Simply run the install command provided by the Keeper vault and make sure Python and the dependencies listed are installed.
Edit the PAM User record previously described in this :
The PAM user record will need all fields as described in the documentation , along with the additional fields below:
Instead of creating the PAM User record manually using the documentation and the extra fields above, you could also import the csv file below. It will create a template record you can amend and duplicate as needed.
Create a PAM User record in the shared folder with the fields and custom fields described .
Provision the gateway (gateway tab after selecting the application) on a Linux box. Simply run the install command provided by the Keeper vault and make sure Python and the dependencies listed are installed.