This blog post is to walk you through creating a service principal in Azure Active Directory. It’s not that difficult, and we have multiple ways to do it. With no further ado, let me show you the steps. Before you start following, make sure you have an Azure account and appropriate permission to create SPN.
Direct link to Azure Active Directory Blade
At the left top corner, the organization name should appear
Click on App registrations. Below wizard appears
Click “+ New Registration”
Now, select Register
Yes, now the active directory application is registered. Next step is to set the credentials. We will create one for an year and renew it later. In the left pane, select Certificates & Secrets – Choose “+ New Client Secret”
Using portal is quick and easy. However using PowerShell is handy. Here is the script for your use.
# Connect-AzAccount -UseDeviceAuthentication
$ServicePrincipal = New-AzADServicePrincipal -DisplayName 'WINTELLISYS-SPN-TST'
$credentials = New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property @{StartDate=Get-Date; EndDate=Get-Date -Year 2024; Password="YOUR SUPER SECRET PASSWORD"}
$ServicePrincipal = New-AzAdServicePrincipal -DisplayName ServicePrincipalName -PasswordCredential $credentials
Explore the $Credentials object to know the password 🙂 – In my next blog post, let me explain in details of ceritificates, service connections in AzDO and much more!