Create a Service Principal in Microsoft Entra ID¶
π StepβbyβStep in the Entra ID UI¶
1. Register a New Application¶
- Sign in to Azure Portal.
- Navigate to Microsoft Entra ID β App registrations.
- Click + New registration.
- Fill in:
-
Name β Friendly name (e.g.,
ansible). - Supported account types β Usually βAccounts in this organizational directory only.β
- Redirect URI β Optional unless you plan to use OAuth flows.
-
Name β Friendly name (e.g.,
- Click Register.
π This creates the Application (client) ID and the associated service principal in your tenant.
2. Create a Client Secret¶
- In your new app registration, go to Certificates & secrets.
- Under Client secrets, click + New client secret.
- Add a description and choose an expiration period.
- Click Add.
- Copy the Value immediately β this is your Client Secret.
β οΈ Important: You wonβt be able to see it again later.
3. Get Tenant ID¶
- In Microsoft Entra ID β Overview, copy the Tenant ID (Directory ID).
4. Assign RBAC Permissions¶
- Go to Subscriptions in the portal.
- Select your subscription.
- Click Access control (IAM) β + Add role assignment.
- In the wizard:
- Role β Pick Contributor (or whatever role you want, e.g. Privileged administrator roles > Contributor).
- Assign access to β Change this from User, group, or service principal to specifically include service principal.
- Members β Click + Select members.
- In the search box, type the name of your app registration (the friendly name you gave it when you registered).
- It will appear under Enterprise applications.
- Select it, then click Review + assign.
5. Collect the Four Values¶
You now have:
- Client ID β Application (client) ID from the app registration.
- Client Secret β Value from Certificates & secrets.
- Tenant ID β Directory ID from Entra ID overview.
- Subscription ID β From Subscriptions overview.
These four values are what Ansible uses to authenticate and obtain tokens.
β Summary¶
- In the Entra ID UI, you register an app β this creates the service principal.
- You then create a client secret and assign RBAC permissions.
- Collect Client ID, Client Secret, Tenant ID, Subscription ID.
- Store them securely (e.g., Ansible Vault) and use them in your automation.