
Creating a Service Principal via Azure Portal / Entra Admin Center
-
Access Microsoft Entra ID in the Azure Portal

-
Navigate to “Manage” > “App registrations”

-
Click ”+ New registration”, complete the form, and click “Register”

-
Go to “Certificates & secrets” > ”+ New client secret”


- Fill in the required fields and click “Add”, then copy the generated value
Creating a Service Principal from Azure CLI
To create a Service Principal using the Azure CLI, follow these steps:-
Open a terminal and execute the following command:
-
The output will be similar to:
-
Save the values of
appId,passwordandtenant, as they will be used as credentials in Prowler.
Creating the Service Principal and Its Permissions with a Script (Optional)
Added in: 5.52.0 As an alternative to the manual steps on this page and in Required Permissions, the Prowler repository includes a script that creates the Service Principal and assigns every permission in one run:permissions/prowler-azure-m365-scan-identity.sh.
The script is a single Bash file that only calls the Azure CLI. It uses the cloud and tenant the Azure CLI is signed in to, and no endpoint is hardcoded. A tenant administrator runs the script. Prowler never receives administrator access.
What the Script Creates
- An app registration (single tenant) and its Service Principal, named “Prowler Scan” unless
--app-nameis set. - The Microsoft Graph application permissions
AuditLog.Read.All,Directory.Read.AllandPolicy.Read.All, with admin consent granted. - The
ProwlerRolecustom role from prowler-azure-custom-role, unless it already exists or--skip-custom-roleis set. - The
ReaderandProwlerRolerole assignments on each subscription, or on one management group, passed as a flag. - Optionally, a client secret (
--client-secret), printed once on the terminal and stored nowhere else. It expires after 180 days.
Required Roles
The person running the script needs:- Microsoft Entra ID: Privileged Role Administrator or Global Administrator, to grant the Microsoft Graph application permissions. If users cannot register applications in the tenant, also Application Developer or Cloud Application Administrator.
- Azure: Owner or User Access Administrator on each subscription or on the management group, to create the custom role and assign roles.
Running the Script
-
Download the script from the repository and read it. Every command that changes something goes through one function,
run, which prints the command before running it. -
For a cloud other than Azure commercial, select it in the Azure CLI first:
Then sign in to the tenant:
-
To see what the script would do, run it without
--apply. This is a dry run: it prints every command and changes nothing.To cover several subscriptions, repeat--subscription. To cover every subscription under a management group, use--management-group <management-group-id>instead. -
To create the identity, run the same command with
--apply: - Copy the Tenant ID, Client ID and client secret from the output. The client secret is shown only once. Wait about a minute before the first scan: a new app registration and its credential take a moment to become usable for sign-in.
[exists] and left unchanged. When an app registration with the same name already exists, the script shows how many owners and credentials it has and stops; to continue, for example on a second run, add --use-existing-app. To use one identity for Azure and Microsoft 365, pass --azure and --m365 together.
Removing What the Script Created
Delete the app registration only if it was created for Prowler. If the script ran with--use-existing-app on an app that other workloads use, remove only what the script added and leave the app in place: the role assignments, the three Microsoft Graph application permissions (and their admin consent) and the prowler-scan credential. If the script also ran with --m365, remove the Microsoft 365 permissions and the Global Reader assignment too, as described in Removing What the Script Created in the Microsoft 365 guide.
-
To remove the role assignments, run the following command for each subscription or management group:
-
To remove the app registration, its Service Principal, its credentials and its Microsoft Graph permissions:
The deleted app registration stays in “Deleted applications” in Microsoft Entra ID for 30 days, where it can be restored or deleted permanently.
-
To remove the custom role, when no other identity uses it:

