AZ-400 exam dumps

AZ-400 practice question 138 of 306

Designing and Implementing Microsoft DevOps Solutions. Professional level, Microsoft. Free question with the correct answer and a full explanation.

AZ-400 Question 138

Single answer

You manage a monorepo in Azure DevOps containing multiple microservices. You need a YAML pipeline for Microservice A that only runs when changes are committed to the 'ServiceA/' folder on the 'main' branch. Which YAML configuration correctly implements this requirement?

  1. A

    trigger: branches: include: - main paths: include: - 'ServiceA/*'

  2. B

    trigger: branches: exclude: - main paths: exclude: - 'ServiceA/*'

  3. C

    trigger: branches: include: - main paths: include: - 'ServiceA' exclude: - 'Database/*'

  4. D

    stages:

    • stage: Build condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
Show answer and explanation

Correct answer: A

Explanation

In Azure DevOps YAML pipelines, you can control continuous integration triggers using 'branches' to include or exclude specific branches and 'paths' to include or exclude folders. The correct snippet uses 'include' on the 'main' branch and aims the path filter at 'ServiceA/*'. Reference: https://learn.microsoft.com/azure/devops/pipelines/repos/github?view=azure-devops#yaml-triggers (similar concepts apply for Azure Repos), which covers specifying branch and path triggers in YAML.

  • A. Correct.

    Correct. This configuration ensures that the pipeline is triggered only on the 'main' branch and only when changes occur within the 'ServiceA/' folder. Both 'branches' and 'paths' are explicitly included.

  • B. Incorrect.

    Incorrect. Excluding the 'main' branch and the 'ServiceA/*' folder would prevent any build from triggering under those conditions. This is the opposite of what is required.

  • C. Incorrect.

    Incorrect. Although the branch and include path partially match the requirement, specifying 'ServiceA' without the '/' wildcard might not correctly capture all files, and there's no need to exclude 'Database/' for this specific requirement.

  • D. Incorrect.

    Incorrect. This condition checks whether the build is on the main branch but does not restrict changes to the 'ServiceA' folder. It would trigger for all changes on the main branch.

Timed practice exam

Take a AZ-400 practice test under exam conditions

70 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam