Project

General

Profile

Create a Service Principal in Microsoft Entra ID

πŸ“˜ Step‑by‑Step in the Entra ID UI

1. Register a New Application

  1. Sign in to Azure Portal.
  2. Navigate to Microsoft Entra ID β†’ App registrations.
  3. Click + New registration.
  4. 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.
  5. Click Register.
    πŸ‘‰ This creates the Application (client) ID and the associated service principal in your tenant.

2. Create a Client Secret

  1. In your new app registration, go to Certificates & secrets.
  2. Under Client secrets, click + New client secret.
  3. Add a description and choose an expiration period.
  4. Click Add.
  5. 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

  1. Go to Subscriptions in the portal.
  2. Select your subscription.
  3. Click Access control (IAM) β†’ + Add role assignment.
  4. 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.
  5. 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.