Question

Difficulty: EasyApp Registrations and Service Principals

You need to use the Azure CLI to create a new application registration in Microsoft Entra ID, instantiate its service principal, and grant the service principal Contributor access to a resource group.

Which sequence of commands should you perform? To answer, move all the actions from the list of actions to the answer area and arrange them in the correct order.

  1. 1Run `az login` to authenticate the Azure CLI session.
  2. 2Run `az ad app create` to register the application in Microsoft Entra ID.
  3. 3Run `az ad sp create` to instantiate a service principal for the registered application.
  4. 4Run `az role assignment create` to assign the Contributor role to the service principal.

Answer

The correct sequence of actions is: First, run `az login` to authenticate. Second, run `az ad app create` to register the application. Third, run `az ad sp create` to create a service principal for the registered application. Fourth, run `az role assignment create` to assign the Contributor role to the service principal.
The correct sequence begins with authenticating via `az login`. Next, the application registration must be created using `az ad app create` to obtain the Application ID. Then, a service principal must be instantiated in the tenant via `az ad sp create` using that Application ID. Finally, role-based access control (RBAC) is configured by running `az role assignment create` to grant the service principal the Contributor role.

Step-by-Step Solution

1
Run `az login` to authenticate the session.
The CLI session is authenticated with Azure.
Authentication is a prerequisite for executing any commands that interact with Azure resources or Microsoft Entra ID.
2
Run `az ad app create` to register the application.
The application object is created in Microsoft Entra ID, generating an Application (client) ID.
An application object must exist in the directory before a service principal can be created for it.
3
Run `az ad sp create` to create the service principal.
A service principal object is created in the tenant, linked to the application registration.
The service principal acts as the security identity (credential holder) that can be assigned roles in Azure.
4
Run `az role assignment create` to grant access.
The service principal is assigned the Contributor role on the resource group.
Azure RBAC roles can only be assigned to existing security principals, such as the newly created service principal.

Key Concept

An Application Registration creates the global definition of the application, while a Service Principal is the local representation (security principal) in a specific tenant that receives role assignments and permissions.
Estimated Time:1m 0s
Rate this question