0
0
Azurecloud~10 mins

Service principals for applications in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a service principal using Azure CLI.

Azure
az ad sp create-for-rbac --name [1]
Drag options to blanks, or click blank then click option'
A"MyAppSP"
B"MyApp"
C"ServicePrincipal"
D"AppService"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic name that does not identify the service principal.
Omitting quotes around the name.
2fill in blank
medium

Complete the code to assign the 'Contributor' role to the service principal.

Azure
az role assignment create --assignee [1] --role Contributor --scope /subscriptions/00000000-0000-0000-0000-000000000000
Drag options to blanks, or click blank then click option'
A"Contributor"
B"<appId>"
C"<objectId>"
D"MyAppSP"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the service principal name instead of appId.
Using the role name as assignee.
3fill in blank
hard

Fix the error in the command to list service principals filtered by display name.

Azure
az ad sp list --filter "displayName eq '[1]'"
Drag options to blanks, or click blank then click option'
Amyappsp
BMyApp
CMyAppSP
Dmyapp
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase letters when the name is case-sensitive.
Using partial names that do not match exactly.
4fill in blank
hard

Fill both blanks to create a service principal and output its appId and password.

Azure
sp=$(az ad sp create-for-rbac --name [1] --query [2] -o json)
echo $sp
Drag options to blanks, or click blank then click option'
A"MyAppSP"
B[appId, password]
C[appId, secret]
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect field names in the query.
Using the wrong service principal name.
5fill in blank
hard

Fill all three blanks to assign a role to a service principal with a specific scope and output the assignment ID.

Azure
assignment=$(az role assignment create --assignee [1] --role [2] --scope [3] --query id -o tsv)
echo $assignment
Drag options to blanks, or click blank then click option'
A"<appId>"
B"Contributor"
C"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup"
D"Reader"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong role name.
Using subscription scope instead of resource group scope.
Using service principal name instead of appId.