exam questions

Exam AZ-400 All Questions

View all questions & answers for the AZ-400 exam

Exam AZ-400 topic 4 question 45 discussion

Actual exam question from Microsoft's AZ-400
Question #: 45
Topic #: 4
[All AZ-400 Questions]

DRAG DROP -
You plan to use Azure Kubernetes Service (AKS) to host containers deployed from images hosted in a Docker Trusted Registry.
You need to recommend a solution for provisioning and connecting to AKS. The solution must ensure that AKS is RBAC-enabled and uses a custom service principal.
Which three commands should you recommend be run in sequence? To answer, move the appropriate commands from the list of commands to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Step 1 : az acr create -
An Azure Container Registry (ACR) can also be created using the new Azure CLI. az acr create
--name <REGISTRY_NAME>
--resource-group <RESOURCE_GROUP_NAME>
--sku Basic
Step 2: az ad sp create-for-rbac
Once the ACR has been provisioned, you can either enable administrative access (which is okay for testing) or you create a Service Principal (sp) which will provide a client_id and a client_secret. az ad sp create-for-rbac
--scopes /subscriptions/<SUBSCRIPTION_ID>/resourcegroups/<RG_NAME>/providers/Microsoft.ContainerRegistry/registries/<REGISTRY_NAME>
--role Contributor
--name <SERVICE_PRINCIPAL_NAME>

Step 3: kubectl create -
Create a new Kubernetes Secret.
kubectl create secret docker-registry <SECRET_NAME>
--docker-server <REGISTRY_NAME>.azurecr.io
--docker-email <YOUR_MAIL>
--docker-username=<SERVICE_PRINCIPAL_ID>
--docker-password <YOUR_PASSWORD>
Reference:
https://thorsten-hans.com/how-to-use-private-azure-container-registry-with-kubernetes

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
TosO
Highly Voted 4 years, 7 months ago
1. az ad sp create-for-rbac - create the service principle 2. az aks create - create the aks with the service principle 3. az role assignment - delegate access to other resources
upvoted 181 times
canbe20
3 years, 9 months ago
Moreover az ad sp create-for-rbac can create the role assignment too, so you don't need to repeat it using az role assignment but run kubectl create
upvoted 7 times
...
rdemontis
2 years, 6 months ago
agree with you! https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal
upvoted 6 times
...
Duleep
4 years, 3 months ago
"The solution must ensure that AKS is RBAC-enabled" So it need "kubectl create"
upvoted 4 times
s9p3r7
3 years, 2 months ago
the recommended solution should be for PROVISIONING and CONNECTING
upvoted 5 times
...
...
...
silverdeath
Highly Voted 4 years, 6 months ago
1- az aks create 2- az ad sp create-for-rbac 3- az role assignment create https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal
upvoted 40 times
VinayDev
3 years, 4 months ago
Agree with Silverdeath..
upvoted 3 times
...
rdemontis
2 years, 7 months ago
Agree with you. thanks for sharing the document
upvoted 4 times
rdemontis
2 years, 6 months ago
Looking better at the document you shared I think it is more correct to create the service principal first. So it would become: 1. az ad sp create-for-rbac 2. az aks create 3. az role assignment
upvoted 12 times
...
...
silverdeath
4 years, 6 months ago
typo swap 1 and 2
upvoted 29 times
...
...
ozbonny
Most Recent 8 months ago
az ad sp create-for-rbac az aks create az role assignment create
upvoted 6 times
...
varinder82
11 months ago
Final answer after going through all the comments 1. az ad sp create-for-rbac - create the service principle 2. az aks create - create the aks with the service principle 3. az role assignment - delegate access to other resources
upvoted 11 times
...
yana_b
12 months ago
https://learn.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli 1. az ad sp create-for-rbac 2. az aks create 3. az role assignment
upvoted 5 times
...
CirusD
1 year ago
az ad sp create-for-rbac az aks create az aks get-credentials
upvoted 3 times
...
yana_b
1 year, 2 months ago
https://learn.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli This link evidences that the answer provided by TosO is still valid.
upvoted 2 times
...
zellck
1 year, 4 months ago
1. az ad sp create-for-rbac 2. az aks create 3. az role assignment create https://learn.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli#manually-create-a-service-principal To manually create a service principal with the Azure CLI, use the az ad sp create-for-rbac command. https://learn.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli#specify-a-service-principal-for-an-aks-cluster To use an existing service principal when you create an AKS cluster using the az aks create command, use the --service-principal and --client-secret parameters to specify the appId and password from the output of the az ad sp create-for-rbac command: https://learn.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli#delegate-access-to-other-azure-resources To delegate permissions, create a role assignment using the az role assignment create command. Assign the appId to a particular scope, such as a resource group or virtual network resource.
upvoted 9 times
...
Pukun
1 year, 4 months ago
1. az ad sp create-for-rbac 2. az aks create 3. az aks get-credentials --Use the az ad sp create-for-rbac command to create a custom service principal in Azure Active Directory (AD) with the necessary permissions to interact with AKS. This command will generate the required credentials for the service principal. --Use the az aks create command to create the AKS cluster. This command will provision the AKS cluster with the specified configuration, including RBAC settings. You can specify the custom service principal created in the previous step using the --service-principal and --client-secret parameters. --Use the az aks get-credentials command to retrieve the necessary credentials and configuration to connect to the AKS cluster. This command will download and merge the cluster's kubeconfig file with your local kubeconfig, allowing you to interact with the cluster using kubectl.
upvoted 4 times
...
Fal991l
1 year, 6 months ago
here are the three recommended commands in the correct order: az ad sp create-for-rbac to create a new service principal with a custom name and assign it the Contributor role on your Azure subscription. az aks create to create an AKS cluster and specify the service principal and RBAC enabled. az aks get-credentials to get the Kubernetes configuration files for the AKS cluster and merge them into your local configuration. Explanation: The az ad sp create-for-rbac command creates a new service principal with a custom name and assigns it the Contributor role on your Azure subscription. This command returns the appId, password, and tenant values that are needed to configure AKS. The az aks create command creates an AKS cluster, specifies the custom service principal, and enables RBAC. This command also returns the Kubernetes configuration files that are needed to connect to the cluster. The az aks get-credentials command gets the Kubernetes configuration files for the AKS cluster and merges them into your local configuration. This command enables you to connect to the AKS cluster using kubectl.
upvoted 3 times
Fal991l
1 year, 6 months ago
from GPT
upvoted 1 times
...
...
gregigitty
1 year, 8 months ago
Custom principal -> az ad sp create-for-RBAC. ('az aks create' can create a system managed identity automatically but not a custom principal). Create AKS cluster -> az aks create Connect to the AKS cluster -> az aks get-credentials "Configure kubectl to connect to your Kubernetes cluster using the az aks get-credentials command." https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-cli#connect-to-the-cluster "az role assignment create" - In my opinion this is not needed as the cluster is "RBAC-Enabled", just not assigned any roles.
upvoted 3 times
ParkXD
1 year, 7 months ago
same with the answer from chatGPT: 1. Create a service principal: 2. Create an AKS cluster: 3.Connect to the AKS cluster
upvoted 1 times
...
...
ecpcloud
1 year, 10 months ago
To me all of this seems confusing, as everyone kinda leans towards the most common answer. But it's important to note the "az ad sp create-for-rbac" command can directly specify the role assignment and scope, so that'd eliminate the need for "az role assignment" one. Then, given the question is asking to PROVISION and CONNECT to the cluster, to me the sequence should be: 1. az ad sp create-for-rbac - create the service principal & also assign it the role (Contributor) 2. az aks create - create the aks specifying a custom service principal, i.e. the one from above, so the aks will already have the role 3. az aks get-credentials - specify the rg and cluster-name from above, to get the credentials to connect to it after you've created it But we all know how Microsoft can be in these situations, my answer might be correct but also overthought, while MS just wanted us to do a few simple initial steps... I genuinely don't know
upvoted 9 times
...
Atos
2 years, 1 month ago
Looks like the article has been updated as it clearly states: 1. az ad sp create-for-rbac 2. az aks create 3. az role assignment
upvoted 8 times
...
shafqat
2 years, 2 months ago
3. az aks get-credentials --resource-group <group name> -name <cluster-name> : this is used for connecting from your machine to aks cluster you created in step 2.
upvoted 2 times
matelin
1 year, 8 months ago
Agree. In my opinion the answer is: 1. az ad sp create-for-rbac 2. az aks create 3. az aks get-credentials. The question doesn't tell what Azure services AKS will be connecting to (if any). It only mentions the "Trusted Docker Registry", which doesn't mean ACR necesserily. What it does ask you are the commands for provisioning and CONNECTING to AKS cluster.
upvoted 4 times
...
...
syu31svc
2 years, 2 months ago
https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli 1) az ad sp create-for-rbac 2) az aks create 3) az role assignment create
upvoted 3 times
...
Govcomm
2 years, 3 months ago
az aks create az aks sp create-for-rbac az role assignment
upvoted 2 times
...
Lucario95
2 years, 5 months ago
As per this documentation: https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal You could use: 1) az ad sp create-for-rbac 2) az aks create (specifying the service principal in this command) Or 1) az aks create 2) az ad sp create-for-rbac 3) az role assignment As the solution requires 3 steps, I'll go with the second option
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago