liveBook · Manning

Service principal

As explained in Azure Security

A service principal is an application identity in Microsoft Entra ID that represents software and can authenticate to access Azure resources.

A service principal is an application identity stored in Microsoft Entra ID. Software uses it to authenticate when accessing Azure resources, such as a database, instead of acting as a human user. section 2.1.3

A service principal can sign in with a password or certificate. Protect either credential: anyone who obtains it can impersonate the application and gain access to the Azure environment. Managed identities avoid credential management where supported. section 2.1.4 section 2.14

Configure a service principal around the access it actually needs:

  • Create the application identity, optionally assigning access to Azure resources during creation. section 2.1.4
  • Assign an Azure RBAC role and scope. The service principal is the authorization “who”; the role defines allowed actions over the selected scope. section 2.3.2
  • Store generated credentials outside code and source control, such as protected CI/CD secrets. section 2.1.4 section 11.3.1

CI/CD deployment identity

A GitHub Actions workflow can use a service principal to enable Defender for Cloud plans across Azure subscriptions. Create the identity with a Contributor role scoped to the target subscription, then configure the CI/CD platform with its generated authentication output. OpenID Connect is an alternative that avoids storing secrets in the platform. section 11.3.1

Listing 11.1 Creating a service principal in Microsoft Entra ID
az ad sp create-for-rbac –display-name "githubActionsApp"   #1
    --role Contributor                                    #2
    --scopes /subscriptions/
      bh24babd-fb35-4348-8ec0-b9a058b4722e                #3
    --sdk-auth                                            #4
#1 The display name of the service principal
#2 The role that specifies the necessary permissions
#3 The scope on which the role assignment is applied
#4 The output result compatible with the Azure SDK auth file

This Azure CLI command creates a service principal, assigns the Contributor role at a subscription scope, and formats output for Azure SDK authentication. section 11.3.1

How Azure Security covers it

How deep it goes
Shows creation commands, credential options, and RBAC role-and-scope setup; defers detailed permission coverage.
Examples
Uses MyAmazingApp and githubActionsApp identities for Azure access and Defender for Cloud automation.
What you can do after
Operate/configure it with Azure CLI credentials, an RBAC role, and a resource scope for CI/CD use.
How it connects
Connects application authentication to Azure RBAC, managed identities, OpenID Connect, and GitHub Actions.

Also explained in

Compare how 3 books explain service principal →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Azure Security. The section links point to the parts of the book it draws on.