Question 746 of 823
AZ-400 Practice Question: Design and implement build and release pipelines
You are setting up a GitHub Actions workflow to deploy a containerized application to Azure Kubernetes Service (AKS). You need to securely authenticate to the AKS cluster using a service principal. What is the recommended way to store and use the service principal credentials?
⚠ Common exam trap
It's easy for candidates to confuse storing credentials in Kubernetes secrets (which is valid for in-cluster applications) with the initial authentication needed from an external CI/CD system, or they may think managed identities can be directly assigned to GitHub Actions runners, which is not supported.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Store the service principal credentials as GitHub Actions secrets and reference them in the 'azure/login' action
GitHub Actions secrets are the recommended secure mechanism for storing sensitive credentials like a service principal's client ID and secret. The 'azure/login' action can directly reference these secrets (e.g., `${{ secrets.AZURE_CREDENTIALS }}`) to authenticate to Azure, and then the 'azure/aks-set-context' action uses that authenticated session to connect to the AKS cluster. This approach avoids hardcoding credentials in the workflow file and leverages GitHub's encrypted storage.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use managed identity for GitHub Actions and assign it to the AKS cluster
Why it's wrong here
Azure AD managed identities are designed for Azure-hosted resources (such as VMs, App Services, or an AKS cluster) that need to authenticate to other Azure services without storing credentials. GitHub Actions runs on GitHub-hosted or self-hosted runners that are external to Azure and cannot assume an Azure resource's managed identity, because the identity is only available when the code executes on that specific Azure resource. There is no mechanism to 'assign' a managed identity to GitHub Actions; the correct, secure path for GitHub Actions to authenticate to Azure is to use OpenID Connect (OIDC) with a federated credential or to store service principal credentials as GitHub Actions secrets. Assigning a managed identity to the AKS cluster would only grant the cluster its own identity, not give the GitHub Actions workflow any authority to deploy or manage cluster resources.
- ✗
Store the service principal credentials in a Kubernetes secret in the AKS cluster
Why it's wrong here
Kubernetes secrets are stored in etcd and are designed to inject sensitive data into pods running inside the AKS cluster; since the GitHub Actions workflow runs outside the cluster, it cannot directly read those secrets, and doing so would not authenticate the workflow to Azure. Exposing service principal credentials in a Kubernetes secret also fails because the workflow has no native mechanism to retrieve or use them as part of the 'azure/login' action, making this approach inappropriate for CI/CD authentication.
- ✓
Store the service principal credentials as GitHub Actions secrets and reference them in the 'azure/login' action
Why this is correct
GitHub Actions secrets are encrypted at rest, masked in logs, and injected into the workflow runtime only when explicitly referenced, making them the secure, supported way to pass service principal credentials. The 'azure/login' action accepts these credentials via secret inputs (e.g., 'client-id', 'client-secret', 'subscription-id', 'tenant-id') and uses them to establish an authenticated session with Azure, so storing them as GitHub Actions secrets and referencing them in that action is the correct, best-practice approach.
- ✗
Store the service principal credentials as environment variables in the workflow file
Why it's wrong here
Environment variables defined directly in the workflow file are stored in plaintext in the repository and can be exposed in run logs or debug output, since they do not benefit from GitHub's secret encryption or automatic log masking. Putting service principal credentials in plain environment variables creates a severe security vulnerability and violates Azure DevOps best practices, which require using protected GitHub Actions secrets for any sensitive authentication material.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jul 4, 2026
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.