- An account in your Azure tenant with one of these roles:
- Global Administrator, or
- Application Administrator, or
- Cloud Application Administrator
- Access to the Azure Portal at https://portal.azure.com
What is a service principal / app registration?
When a script or automated process needs to access Azure resources, it cannot log in as a human user. Instead, you create an App Registration, which is essentially an identity for the application itself. The app registration has:- A Client ID — like a username for the application
- A Client Secret — like a password for the application
Step 1 - Open the Azure Portal
- Go to https://portal.azure.com and sign in with your administrator account.
- In the top search bar, type Entra ID and select Microsoft Entra ID from the results.
Step 2 - Create the app registration
- In the left-hand menu, click App registrations.
- Click + New registration at the top.
- Fill in the form:
- Name: Enter a descriptive name, e.g.
Ansys Sync Service(this is just a display name — it does not need to match anything in the script). - Supported account types: Select Accounts in this organizational directory only (Single tenant).
- Redirect URI: Leave blank.
- Name: Enter a descriptive name, e.g.
- Click Register.
Step 3 - Note the client ID
On the Overview page you will see:- Application (client) ID — a GUID that looks like
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
--entra-client-id (or enter at the prompt).
Step 4 - Create a client secret
- In the left-hand menu of your app registration, click Certificates & secrets.
- Click + New client secret.
- Fill in the form:
- Description: e.g.
Ansys Sync Script - Expires: Choose an expiry period appropriate for your organisation. Common choices are 12 months or 24 months. Note: When the secret expires the script will stop working. Set a calendar reminder to rotate it before the expiry date.
- Description: e.g.
- Click Add.
- The secret Value is now shown in the table. Copy it immediately — Azure will never show the full value again after you leave this page. If you lose it you will need to delete it and create a new one.
--entra-client-secret
(or enter at the prompt).
Keep this value secure. Anyone who has both the Client ID and the Client
Secret can authenticate as this application against your Azure tenant.
Step 5 - Assign API permissions
The script needs two Microsoft Graph API permissions to read group membership:- Group.Read.All — allows the app to find the security group by name and read its basic properties.
- User.Read.All — allows the app to read each member’s profile, including their primary email (mail) attribute.
- In the left-hand menu, click API permissions.
- Click + Add a permission.
- In the panel that appears, click Microsoft Graph.
- Click Application permissions.
- In the search box, type
Group.Readand expand Group. Check the box next to Group.Read.All. - Clear the search box, type
User.Readand expand User. Check the box next to User.Read.All. - Click Add permissions.
Step 6 - Grant admin consent
Application permissions (as opposed to permissions a user grants to themselves) require a tenant administrator to explicitly approve them. This is a one-time step.- On the API permissions page, click the button Grant admin consent for [your tenant name].
- A confirmation dialog will appear — click Yes.
- Both permissions should now show a green checkmark and the status Granted for [your tenant name].
Step 7 - Verify the setup
At this point your app registration is complete. As a final check, confirm the following on the Overview page:- Application (client) ID: copied in Step 3
- Directory (tenant) ID: this is your tenant’s GUID — it is NOT needed by the script (the script uses —entra-domain instead) but is useful to have for troubleshooting
- Client secret: copied in Step 4 and stored securely
- Microsoft Graph / Group.Read.All / Application / Granted ✓
- Microsoft Graph / User.Read.All / Application / Granted ✓
Step 8 - Confirm the target security group exists
The script reads the group by its Display Name — the name shown in the Entra ID groups list.- In the left-hand menu of Microsoft Entra ID, click Groups.
- Search for the group you intend to sync.
- Confirm:
- The group exists and the display name is exactly as you will pass
to
--entra-group(spelling and capitalisation must match). - The group type is Security (not Microsoft 365).
- All members of the group have a primary email address set on their user profile. To check a user’s primary email: a. Go to Users, find the user, open their profile. b. Look for the Email field under Contact information. c. This must be populated — if it is blank the user will be skipped by the script with a warning.
- The group exists and the display name is exactly as you will pass
to
Rotating the client secret (annual maintenance)
Client secrets expire. Before expiry:- Go to the app registration → Certificates & secrets.
- Click + New client secret, create a new one, copy the value.
- Update the
--entra-client-secretvalue in your Task Scheduler action (or wherever you store it). - Verify the script runs successfully with the new secret.
- Delete the old (expiring) secret from the Certificates & secrets page.