AZ-401 Domain 4: Design and implement a security and compliance plan
15–20% of the exam (AZ-400: 10–15%). 13 skills in 3 tasks. Study notes for each task below, then 7 free questions with answers.
52 Domain 4 questions in the bank, 7 free. Answer them one at a time with explanations.
Practice Domain 4Skill wording is quoted from the official study guide. Tags compare each skill with the AZ-400 guide.
4.1 Design and implement authentication and authorization methods
Task 4.1 covers the identities that pipelines and people use: managed identities versus service principals, GitHub Apps, GITHUB_TOKEN and personal access tokens, OIDC federation, Azure DevOps service connections, and access levels, roles and teams on both platforms. Most questions hinge on least privilege and on removing stored secrets.
- 4.1.1Choose between Microsoft Entra service principals and managed identities for Azure resources 4 questions
- 4.1.2Implement and manage GitHub authentication, including GitHub Apps, GITHUB_TOKEN, and personal access tokens 5 questions
- 4.1.3Implement and manage secretless authentication in Azure Pipelines and GitHub Actions 5 questions
- 4.1.4Implement and manage Azure DevOps service connections and personal access tokens 5 questions
- 4.1.5Design and implement permissions and access levels in Azure DevOps and GitHub 4 questions
- 4.1.6Configure projects in Azure DevOps (ADO) and GitHub, including ADO teams 3 questions
Service principal or managed identity: which one does a scenario call for?
Source: What is managed identities for Azure resources?; Use service principals and managed identities in Azure DevOps
GITHUB_TOKEN, GitHub App or fine-grained PAT: which token fits which automation?
permissions block lists any permission, every unlisted permission becomes none, so a job that checks out code and opens issues needs contents: read and issues: write. Events caused by GITHUB_TOKEN don't start new workflow runs, except workflow_dispatch and repository_dispatch. The organization setting Allow GitHub Actions to create and approve pull requests controls whether it can open and approve pull requests. A GitHub App isn't tied to a user, uses no seat, survives staff leaving, is limited to the repositories chosen at installation, gets rate limits that scale, and its installation token does trigger workflows. Fine-grained PATs are limited to one resource owner, selected repositories and specific permissions, and organization owners can require approval for them; classic PATs can't be put through approval, so restrict classic token access to the organization instead.Source: GITHUB_TOKEN; Deciding when to build a GitHub App
How do I sign in from GitHub Actions to Azure with OIDC, and why doesn't the federated credential match?
api://AzureADTokenExchange. The job needs id-token: write; it lets the job request a JWT and grants no write access to resources. The subject must match exactly and wildcards aren't supported. A job that references an environment sends repo:ORG/REPO:environment:NAME; a pull request run without an environment sends repo:ORG/REPO:pull_request; otherwise the subject is the ref, such as repo:ORG/REPO:ref:refs/heads/main. Add one credential per context; an app registration allows up to 20. Repositories created, renamed or transferred after July 15, 2026 use an immutable subject with IDs, such as repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main, so a value copied from an older repository won't match.permissions:
id-token: write
contents: read
steps:
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}Source: Configuring OpenID Connect in Azure; OpenID Connect reference
How do Azure DevOps service connections and PATs work without long-lived secrets?
Source: Connect to Azure with an Azure Resource Manager service connection; Manage personal access tokens using policies (for administrators)
Which Azure DevOps access level, role or setting gives each person only what they need?
Source: About access levels; Create or add a team
Which GitHub role, base permission or team structure gives least privilege?
Source: Repository roles for an organization; About organization teams
Traps in 4.1 questions
- Listing only issues: write in a permissions block sets contents to none, so actions/checkout fails; every needed permission must be listed.
- A PAT does trigger workflows like a GitHub App token, but it is tied to a person's account; when the requirement is no user dependency, the answer is a GitHub App.
- When a GitHub Actions job references an environment, the OIDC subject contains the environment, not the branch, so a branch-based federated credential never matches.
- Adding a service principal to a Microsoft Entra group or granting it Entra API permissions does not let it call Azure DevOps; it must be added to the organization with an access level.
26 questions in the bank test task 4.1. Practice Domain 4
4.2 Design and implement a strategy for managing sensitive information in automation
Task 4.2 covers where pipeline secrets live and how they reach a job without leaking: Key Vault integration, secret and key lifecycle, secure files and GitHub secret scopes, and log masking and fork protections. Questions hinge on which store or scope satisfies an approval, rotation or no-leak constraint.
- 4.2.1Integrate Azure Key Vault into Azure Pipelines and GitHub Actions 4 questions
- 4.2.2Implement and manage secrets, keys, and certificates 3 questions
- 4.2.3Design and implement a strategy for managing sensitive information during deployment, including Azure Pipelines secure files and GitHub secrets 4 questions
- 4.2.4Design Azure Pipelines and GitHub Actions to prevent leakage of sensitive information 5 questions
How do I pull Azure Key Vault secrets into Azure Pipelines?
AzureKeyVault@2 task downloads the secrets named in SecretsFilter (a comma-separated list or *) as secret variables for later steps. A Key Vault-linked variable group maps chosen secret names once for many pipelines: value changes flow through at run time, but secrets added to the vault must be selected in the group explicitly. Variable groups map only secrets, not keys or certificates. The identity needs Get and List on secrets with the access policy model, or Key Vault Secrets User at vault scope with the RBAC model; Key Vault Reader returns only metadata and Secrets Officer can also set and delete. Variable groups support RBAC vaults only over a public endpoint, so a vault behind a private endpoint uses the access policy model. Azure DevOps isn't an Azure trusted service.- task: AzureKeyVault@2
inputs:
azureSubscription: 'SERVICE_CONNECTION_NAME'
KeyVaultName: 'KEY_VAULT_NAME'
SecretsFilter: '*'
RunAsPreJob: falseSource: Use Azure Key Vault secrets in Azure Pipelines; Link a variable group to secrets in Azure Key Vault
What do soft delete, purge protection and rotation policies guarantee in Key Vault?
Source: Azure Key Vault soft-delete overview; Configure cryptographic key auto-rotation in Azure Key Vault
Secure files, variable groups or GitHub environment secrets: where do signing files and deployment secrets go?
DownloadSecureFile@1 puts it on the agent. A secure file can be at most 10 MB. A secret pipeline variable can't carry approvals or checks. In GitHub Actions, secrets exist at organization, repository and environment level. Organization secrets are limited by a repository access policy. Environment secrets reach only jobs that reference the environment, and with required reviewers the job can't read them until someone approves; deployment branch rules can restrict the environment to main. Secrets are limited to 48 KB; for larger ones, commit a gpg-encrypted file and store the passphrase as a secret, and use Base64 for small binary blobs. Every job in a repository can read repository secrets, so they don't satisfy an approval requirement.Source: Use secure files; Using secrets in GitHub Actions
Which secrets do Dependabot, fork and Copilot cloud agent runs receive?
secrets context, so one workflow works for human and Dependabot pull requests without changing the trigger. Copilot cloud agent receives only its own Agents secrets and variables, set at repository or organization level; it doesn't get Actions, Codespaces or Dependabot secrets. Only Agents secrets whose names start with COPILOT_MCP_ are available to its MCP server configuration. Secrets once stored in the copilot environment were migrated to the Agents type, and that environment is no longer the supported place for them.Source: Troubleshooting Dependabot on GitHub Actions; Configure secrets and variables for Copilot cloud agent
How do I stop Azure Pipelines from leaking secrets into logs or to untrusted runs?
env: and never pass them on the command line, because some systems log arguments. A value created in a script becomes masked only when set with ##vso[task.setvariable variable=name;issecret=true]; isOutput shares it with later jobs and isreadonly blocks overwrites, but neither masks. Turning on Limit variables that can be set at queue time lets users set only variables marked settable at queue time, from the UI and REST API; set at organization level, projects can't turn it off. For GitHub fork pull requests, the organization control Limit building pull requests from forked GitHub repositories with Securely build withholds secrets, withholds regular-build permissions and requires a pull request comment to start a build.Source: Set secret variables; Build GitHub repositories
How do I use Key Vault values in GitHub Actions without a stored credential or a log leak?
azure/login and OIDC: the job needs permissions: id-token: write, and the workflow stores only the client, tenant and subscription IDs, not a client secret. A value fetched from Key Vault at run time isn't a GitHub secret, so the runner doesn't redact it; emit ::add-mask::VALUE before anything prints it. enable-AzPSSession only adds an Azure PowerShell session. Avoid passing secrets on the command line, because other processes and audit events can see arguments; use environment variables or STDIN. Secrets can't be referenced directly in if: conditions; set them as job-level environment variables and test those. pull_request_target runs with the base repository's token and secrets, so checking out and running the fork's code there exposes them. Run untrusted code under pull_request, which has a read-only token and no secrets, and do privileged follow-up in a workflow_run workflow that doesn't execute pull request code.Source: Use the Azure Login action with OpenID Connect; Securely using pull_request_target
Traps in 4.2 questions
- A Key Vault-linked variable group picks up new values of mapped secrets automatically but never adds new secret names; a missing secret means editing the group, not fixing permissions.
- Key Vault Reader sounds sufficient for reading secrets but returns metadata only; the role that reads secret values is Key Vault Secrets User.
- Soft delete is not enough when nobody may purge: only purge protection blocks purging until the retention period ends.
- An organization Actions secret is still an Actions secret, so Dependabot-triggered runs don't receive it; the fix is a Dependabot secret with the same name.
16 questions in the bank test task 4.2. Practice Domain 4
4.3 Automate security and compliance scanning
Task 4.3 covers automated SAST, SCA, secret and IaC scanning on GitHub and Azure DevOps and surfacing the results in Microsoft Defender for Cloud. Questions hinge on which product licenses which feature, which setup runs without pipeline changes, and which check blocks a pull request.
- 4.3.1Design a strategy for security, vulnerability, and compliance scanning 2 questions
- 4.3.2Configure dependency scanning, code scanning, and secret scanning by using GitHub Advanced Security for Azure DevOps and GitHub Advanced Security 5 questions
- 4.3.3Connect Microsoft Defender for Cloud DevOps Security to other DevOps environments, including Azure DevOps and GitHub 3 questions
Which tool covers each layer of a security scanning strategy?
Source: Configuring the dependency review action; About GitHub Advanced Security
How are GitHub Advanced Security products split and billed on GitHub and Azure DevOps?
Source: Configure GitHub Advanced Security for Azure DevOps; Advanced Security billing
How do I set up CodeQL and dependency scanning in Azure DevOps and block risky pull requests?
AdvancedSecurity-Codeql-Init@1 (set languages) and AdvancedSecurity-Codeql-Analyze@1. Self-hosted agents need the CodeQL bundle in the tool cache; enableAutomaticCodeQLInstall: true installs it. Dependency scanning uses AdvancedSecurity-Dependency-Scanning@1, or the repository setting Scan for vulnerable dependencies injects it into pipelines that target the default branch. Disabling Marketplace tasks breaks both. To block merges, add a status check branch policy: AdvancedSecurity/AllHighAndCritical requires every existing critical and high alert to be fixed, while AdvancedSecurity/NewHighAndCritical blocks only new ones and needs a build validation pipeline that scans the PR branch.Source: Code scanning for GitHub Advanced Security for Azure DevOps; Configure GitHub Advanced Security for Azure DevOps
How does secret push protection work, and how is a false positive bypassed on each platform?
skip-secret-scanning:true in the commit message, and an alert is still created so the bypass can be audited.Source: Push protection; Secret scanning for GitHub Advanced Security for Azure DevOps
What permissions and steps connect Azure DevOps, GitHub and GitLab to Defender for Cloud?
Source: Connect Azure DevOps environments to Defender for Cloud; Quick Start: Connect your GitHub Environment to Microsoft Defender for Cloud
What do agentless code scanning and pull request annotations in Defender for Cloud require?
Source: Support and prerequisites: DevOps security; Enable pull request annotations in GitHub and Azure DevOps
Traps in 4.3 questions
- AdvancedSecurity/AllHighAndCritical blocks every pull request while an existing backlog remains; to stop only newly introduced issues use AdvancedSecurity/NewHighAndCritical.
- Default setup in Azure DevOps doesn't scan Go or Swift; those need advanced setup with the CodeQL tasks, and self-hosted agents need enableAutomaticCodeQLInstall or a cached bundle.
- Project Administrator in every project does not replace Project Collection Administrator for the Defender for Cloud Azure DevOps connector, and Stakeholder access is not enough.
- Dismissing an alert does not unblock a push; in Azure DevOps a false positive is pushed with skip-secret-scanning:true, and on GitHub the pusher selects a bypass reason.
10 questions in the bank test task 4.3. Practice Domain 4

Free Domain 4 questions
A GitHub Actions workflow must deploy to Azure without storing a client secret. The Microsoft Entra app registration has a federated credential that matches the workflow, and the repository secrets AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_SUBSCRIPTION_ID exist. The azure/login step fails because the job can't request an OIDC token. What should you change?
on:
push:
branches: [main]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- Add a creds input that contains the service principal JSON from a repository secret.
- Change contents: read to contents: write so that the token can be exchanged.
- Add id-token: write to the workflow-level permissions block.
- Add actions: write to the permissions block so the job can reach the OIDC provider.
Show answer and explanation
Answer: C. A job needs id-token: write so that GitHub's OIDC provider issues a JSON Web Token that azure/login exchanges for an Azure access token. Because the workflow declares permissions, every permission it doesn't list is none, so id-token must be added explicitly; it doesn't grant write access to any resource.
Why the other options are wrong:
- A. A creds JSON contains a client secret, which violates the no-secret requirement.
- B. contents controls repository contents and has nothing to do with requesting an OIDC token.
- D. actions controls workflow runs; only id-token: write allows the job to fetch an OIDC token.
Documentation: Configuring OpenID Connect in Azure; Workflow syntax for GitHub Actions
Contoso, Ltd. runs an Azure Functions app named func-orders that reads blobs from a storage account named stinvoices. The security team requires that no credential for this access be stored in code, app settings, or Azure Key Vault. The identity must be usable only by func-orders, and it must be removed automatically if func-orders is deleted. You need to configure authentication with the least administrative effort. What should you use?
- A user-assigned managed identity that is assigned to func-orders and granted Storage Blob Data Reader
- An app registration whose certificate is kept in Key Vault and loaded through a Key Vault reference
- An app registration that has a client secret stored as an encrypted application setting
- A system-assigned managed identity on func-orders that is granted Storage Blob Data Reader
Show answer and explanation
Answer: D. A system-assigned managed identity is created as part of the Azure resource, only that resource can use it to request tokens, and Azure deletes its service principal when the resource is deleted. Azure manages the credential, so nothing is stored, and you only enable the identity and add one role assignment.
Why the other options are wrong:
- A. A user-assigned identity has an independent lifecycle, must be deleted explicitly, and can be attached to other resources, which breaks two of the requirements.
- B. The certificate is a stored credential in Key Vault that you must rotate, which the security team prohibits.
- C. A client secret in an app setting is a stored credential and adds rotation work.
Documentation: What is managed identities for Azure resources?
Your GitHub organization sets the default GITHUB_TOKEN workflow permissions to the restricted setting. A repository contains the following workflow. The job must check out the code, run a script, and open an issue that lists stale dependencies. You need to replace the comment with a permissions block that grants the least privilege that lets the job succeed. What should you use?
name: stale-deps
on:
schedule:
- cron: '0 2 * * *'
jobs:
report:
runs-on: ubuntu-latest
# permissions block goes here
steps:
- uses: actions/checkout@v5
- run: ./scripts/find-stale.sh > report.md
- run: gh issue create --title "Stale dependencies" --body-file report.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- permissions: { issues: write }
- permissions: { contents: read, issues: write }
- permissions: { contents: write, issues: write }
- permissions: { contents: read, pull-requests: write }
Show answer and explanation
Answer: B. When a permissions block lists any permission, every permission that isn't listed is set to none. The checkout step needs contents: read, and gh issue create needs issues: write, so both must be listed and nothing more.
Why the other options are wrong:
- A. Listing only issues sets contents to none, so actions/checkout can't read the repository.
- C. contents: write lets the job push commits and create releases, which is more than the job needs.
- D. pull-requests: write doesn't allow creating issues, so gh issue create fails.
Documentation: Workflow syntax for GitHub Actions; Use GITHUB_TOKEN for authentication in workflows
Contoso has an Azure DevOps organization that contains only private projects. You need to assign access levels at the lowest cost. Sixty business owners must view and edit work items and approve releases but never open code. Six QA leads must create test plans and test suites and author manual test cases. None of these users has a Visual Studio subscription or GitHub Enterprise license. Which two assignments should you make? Each correct answer presents part of the solution. (Choose TWO.)
Choose TWO.
- Business owners: Stakeholder
- Business owners: Basic
- QA leads: Basic
- QA leads: Basic + Test Plans
- QA leads: Stakeholder
Show answer and explanation
Answer: A and D. Stakeholder access is free for unlimited users and covers creating and editing work items and viewing and approving release pipelines, but not Azure Repos. Creating test plans and suites and authoring manual test cases is Test Case Management, which needs Basic + Test Plans or an equivalent Visual Studio subscription.
Why the other options are wrong:
- B. Basic is a paid level, and these users don't need code access.
- C. Basic doesn't include web-based test case management for creating test plans and suites.
- E. Stakeholders have no access to Azure Test Plans in private projects.
Documentation: About access levels; Stakeholder access quick reference
You have an Azure DevOps project named Contoso. Twelve YAML pipelines reference a variable group named prod-secrets that is linked to an Azure key vault named kv-prod. When the security team rotates the value of an existing secret, the pipelines pick up the new value on the next run. Yesterday the team added a new secret named PaymentApiKey to kv-prod, but $(PaymentApiKey) doesn't resolve in any pipeline run. You need the pipelines to receive the new secret with the LEAST administrative effort. What should you do?
- Grant the service connection's identity the List permission on secrets in kv-prod.
- Edit the prod-secrets variable group and add PaymentApiKey to its mapped secrets.
- Reauthorize the service connection that prod-secrets uses on the Library page.
- Add an AzureKeyVault@2 task with SecretsFilter set to '*' to all twelve pipelines.
Show answer and explanation
Answer: B. A Key Vault-linked variable group maps secret names, not values. Value changes to secrets that are already mapped flow through automatically at runtime, but secrets added to or deleted from the vault are not added to the group; you must select them explicitly. Adding PaymentApiKey to the group fixes all twelve pipelines in one place.
Why the other options are wrong:
- A. Existing secrets already resolve, so the identity clearly has Get and List; permissions aren't the gap.
- C. The connection already works for the mapped secrets; reauthorizing doesn't add the new secret name to the group.
- D. This would work but means editing twelve pipelines, which isn't the least effort when one variable group edit is enough.
Documentation: Link a variable group to secrets in Azure Key Vault
An Azure Pipelines secret variable named SvcConfig holds a JSON document that contains a service account name and password. A deployment script parses SvcConfig and, on failure, writes the parsed password to the log. Reviewers see the password in clear text even though SvcConfig is marked secret. You need to reduce the chance that such values appear in logs. What should you do?
- Store each sensitive value as its own secret variable and map each one to an environment variable.
- Turn on the Limit variables that can be set at queue time setting for the project.
- Declare SvcConfig in YAML with readonly: true so that scripts can't change its value.
- Set System.Debug to false so that the agent doesn't write diagnostic output.
Show answer and explanation
Answer: A. Azure Pipelines masks the exact secret value but never masks substrings. A field taken out of a structured secret, such as JSON, isn't masked. Microsoft advises against storing structured data in secrets; one secret per sensitive value, mapped explicitly into the environment, keeps each value maskable.
Why the other options are wrong:
- B. This stops users from adding or overriding variables at queue time; it does nothing for log masking.
- C. Read-only stops changes to the variable, not its contents appearing in logs.
- D. The script itself writes the value; debug logging isn't the cause.
Documentation: Set secret variables
Contoso uses GitHub Advanced Security for Azure DevOps with secret push protection enabled on all Azure Repos repositories. A developer's push is rejected because a unit-test fixture contains a dummy connection string. The team confirms that it isn't a real credential. Policy requires push protection to stay enabled on the repository. What should the developer do?
- Include skip-secret-scanning:true in the commit message and push the commit again.
- Ask a Project Administrator to dismiss the secret alert, then retry the same push.
- Ask a Project Collection Administrator to turn off push protection briefly for the push.
- Make the same change in the Azure Repos web editor, which push protection doesn't check.
Show answer and explanation
Answer: A. In Azure DevOps, a developer can bypass a push protection block for a confirmed false positive by putting skip-secret-scanning:true in the commit message. Push protection stays on, and a secret scanning alert is still created after the push, so the bypass can be audited.
Why the other options are wrong:
- B. A blocked push never reaches the repository, so there's no alert to dismiss, and dismissal doesn't unblock pushes.
- C. Turning off push protection, even briefly, breaks the policy.
- D. Push protection also blocks secrets in commits made through the web interface.
Documentation: Secret scanning for GitHub Advanced Security for Azure DevOps
The full bank has 45 more Domain 4 questions and 20-question Domain 4 drills that serve unseen questions first.
Domain 4 drill: $19.99