Developments in Digital
Developments in Digital

Logging in as service principal for local development

When running release pipelines within Azure AD, a service connection is used to execute any Azure PowerShell task. This is associated with a service principal within Azure AD.

To speed up the development lifecycle, you can login locally as the service principal used by the service connection. This allows you to exeucte PowerShell cmdlets locally under the same permissions as the service connection running in Azure DevOps.

You will need the credentials for the service principal:

  1. Find the associated app registration within Azure AD to locate the application id.
  2. Under 'Settings' -> 'Keys' generate a key and make a note of it.
  3. Under Azure AD -> Properties, make a note of the directory id (tenant id).

To login locally as the service principal, run the following PowerShell:

$credential = Get-Credential
Connect-AzureRmAccount -Credential $credential -Tenant "<tenantid>" -ServicePrincipal

You will be prompted for username/password.

You can use the application id for the username and the key value for the password.