Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Assign roles at different scopes

A worked example

Multiple answers

An automation service principal named sp-deploy is assigned the Owner role at the subscription scope. sp-deploy has no Microsoft Entra directory roles. A pipeline runs the commands in the exhibit to grant a user access to the resource group rg-web. The pipeline fails.

Requirements:

  • The new assignment must stay scoped to rg-web.
  • sp-deploy must not receive additional Azure resource roles.
az login --service-principal --username "<app-id>" --password "<secret>" --tenant "<tenant-id>"
az role assignment create --assignee "dana@contoso.com" --role "Reader" --scope "/subscriptions/<sub-id>/resourceGroups/rg-web"

ERROR: Insufficient privileges to complete the operation.

Which two changes would each resolve the error while meeting the requirements? Select two.

Choose 2 answers.
Why

With --assignee, Azure CLI resolves the user through Microsoft Entra ID, and a service principal cannot read the directory by default. This happens even when the service principal is Owner on the subscription. You can fix it by giving the service principal the Directory Readers directory role. You can also pass the object ID with --assignee-object-id so that the lookup is skipped. Both fixes keep the assignment at rg-web and add no Azure resource roles.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free