AZ-401 security and compliance explained
The security and compliance domain is 15-20% of AZ-401 and asks one question over and over: how does automation prove who it is, where do secrets live, and what scans catch problems before release? Microsoft’s beta outline has three groups: authentication and authorization, sensitive information in automation, and security and compliance scanning. Expect to choose the least-privilege, least-secret option.
Authentication and authorization
Identity for Azure resources. Managed identities are the default for code running on Azure: Azure issues and rotates the credential, and you never see it. Use a Microsoft Entra service principal when the caller is outside Azure, such as a pipeline, and you need an identity you create yourself. The outline names this choice explicitly.
Secretless pipelines. Workload identity federation lets Azure Pipelines (through a service connection) and GitHub Actions (through OIDC) trade a short-lived token for Azure access. There is no client secret to store, expire or leak. When you can federate, federate.
GitHub credentials.
| Credential | Best for |
|---|---|
| GITHUB_TOKEN | Workflow-scoped access to the same repository; expires when the job ends |
| GitHub App | Automation across repositories or an organization, with fine-grained permissions not tied to a person |
| Personal access token | Last resort; tied to a user and long-lived |
Restrict the default GITHUB_TOKEN permissions in workflows and grant extra ones only per job.
Azure DevOps. Service connections hold the identity for deployments; limit which pipelines may use them and add approvals for production ones. Personal access tokens should be short-lived and scoped. Also know permissions and access levels in both platforms, and how projects and teams are structured in Azure DevOps.
Sensitive information in automation
- Key Vault stores secrets, keys and certificates. Pipelines read it through an integration, and the identity needs only get and list on the secrets it uses. Prefer Azure RBAC for access.
- Platform secrets (Azure Pipelines secure files, variable groups with secret values, GitHub secrets) are for values that cannot come from Key Vault or federation.
- Preventing leakage: mask secrets in logs, never echo them, avoid passing them on command lines, keep secrets out of pull requests from forks, and watch for untrusted input injected into scripts. Rotate anything that has been exposed.
The exam often puts three options side by side: a stored secret, a Key Vault reference and federation. Rank them from worst to best in that order.
Security and compliance scanning
Design where scans run and what blocks a release. The outline names:
- Dependency scanning for vulnerable libraries and license issues.
- Code scanning for flaws in your own code (static analysis, for example CodeQL on GitHub).
- Secret scanning for committed credentials, ideally with push protection that blocks them up front.
- GitHub Advanced Security for both GitHub and Azure DevOps, and Microsoft Defender for Cloud DevOps security, which connects to Azure DevOps and GitHub environments to give security teams one view.
Shift left: run fast scans on pull requests and heavier ones on a schedule or before release.
Common traps
- Storing a client secret when federation is available.
- Using a personal access token for a shared pipeline.
- Granting a pipeline Contributor on the whole subscription instead of the one resource group it deploys to.
- Scanning only at release time, when fixes are costly.
Three practice questions
Question 1. A GitHub Actions workflow must deploy to one Azure resource group. The security team wants no stored credentials and the narrowest permission. What do you set up?
- A. A service principal secret stored as a repository secret, with Owner on the subscription
- B. A personal access token of the lead developer
- C. A federated credential with a role assignment scoped to the resource group
- D. A shared administrator password in the workflow file
Show answer
Answer: C
A federated credential on a Microsoft Entra identity, with a role assignment scoped to the one resource group, gives secretless access with least privilege. A stored secret still has to be protected and rotated, and Owner on the subscription is far broader than needed.
Want more questions like this? Full AZ-401 practice tests →
Question 2. A shared automation needs to read and write issues across ten repositories in a GitHub organization and must not depend on any employee account. Which authentication is most appropriate?
- A. A GitHub App installed on the ten repositories
- B. The GITHUB_TOKEN of one workflow
- C. A personal access token of a team member
- D. Anonymous access
Show answer
Answer: A
A GitHub App has its own identity, fine-grained permissions and installation across selected repositories, independent of any person. GITHUB_TOKEN only covers the repository running the workflow, and personal access tokens are tied to a user who may leave.
Want more questions like this? Full AZ-401 practice tests →
Question 3. Developers sometimes commit credentials by mistake. You want the commit blocked before the secret reaches the repository history. What should you enable?
- A. Dependency scanning only
- B. A manual repository review each quarter
- C. Code scanning on pull requests only
- D. Secret scanning with push protection
Show answer
Answer: D
Secret scanning with push protection checks pushes and blocks those containing known secret patterns before they land in history. Dependency scanning looks at libraries, a quarterly manual review finds problems late, and code scanning on pull requests detects flaws in code rather than blocking a credential push.
Want more questions like this? Full AZ-401 practice tests →
Next: instrumentation.