AZ-400 exam dumps

AZ-400 practice question 133 of 306

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

AZ-400 Question 133

Select 2

You are configuring a YAML-based build pipeline in Azure Pipelines that is integrated with a GitHub repository. The repository's source code is located in the 'src' folder, and the pipeline YAML file is named 'azure-pipelines.yml' in the repository root. The development team wants the pipeline to run automatically only when a pull request is opened or updated if there are changes in the 'src' folder or the pipeline definition file. Which two actions should you perform to achieve this requirement?

  1. A
    1. In azure-pipelines.yml, set 'trigger: none', then configure 'pr:' with 'branches: [main]' and path filters for 'src/*' and 'azure-pipelines.yml'.
  2. B
    1. In azure-pipelines.yml, configure 'trigger: [main]' so the pipeline runs on every push to the main branch.
  3. C
    1. In GitHub, enable manual status checks for the repository, requiring the pipeline to be approved before merging pull requests.
  4. D
    1. Authorize Azure Pipelines as a GitHub App in the project settings, and enable 'Build Pull Request Validation' in the pipeline configuration with path filters for 'src/*' and 'azure-pipelines.yml'.
Show answer and explanation

Correct answers: A, D

Explanation

To integrate a GitHub repository with Azure Pipelines for pull request triggers restricted to specific paths, you must first ensure Azure Pipelines is authorized to access the repository. In the YAML pipeline, setting 'trigger: none' prevents unwanted triggers on direct pushes, and using 'pr:' configuration with 'branches' and 'paths' instructs the pipeline to run only for certain paths on pull requests. Additionally, enabling Build Pull Request Validation under the pipeline's settings in Azure DevOps (after authorizing as a GitHub App) ensures the pipeline is recognized as a required check in GitHub pull requests. Refer to Microsoft� official documentation on YAML triggers (https://docs.microsoft.com/azure/devops/pipelines/yaml-schema/pr) for more details on configuring PR triggers and path filters.

  • A. Correct.

    Option 1 is correct. Setting 'trigger: none' disables automatic builds on direct pushes. Defining 'pr:' with the correct branch and path filters ensures that only pull requests affecting 'src/*' or 'azure-pipelines.yml' trigger the pipeline.

  • B. Incorrect.

    Option 2 is incorrect. Using 'trigger: [main]' alone instructs Azure Pipelines to run on every push to the main branch, but does not control pull request triggers or path filtering. This would cause the pipeline to run more often than required.

  • C. Incorrect.

    Option 3 is incorrect. Manually enabling status checks in GitHub means you must manually approve or enforce those checks, but it does not automatically configure or restrict the trigger to specific paths within the repository. This also does not handle the path-based filtering requirement in the pipeline itself.

  • D. Correct.

    Option 4 is correct. Authorizing the pipeline as a GitHub App is a prerequisite for integrating GitHub with Azure Pipelines. Enabling 'Build Pull Request Validation' and specifying path filters in the pipeline settings ensures the pipeline runs only for pull requests that modify 'src/*' or the pipeline file.

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