AZ-400 Question 134
Select 2You are setting up a continuous integration process in Azure Pipelines using a GitHub repository. Your organization requires that every pull request (PR) to the main branch automatically triggers a build and test run. Which two actions should you take to ensure that the Azure Pipelines build is triggered for every new PR from GitHub?
- A
A. Define a 'pr' trigger in your Azure Pipelines YAML file pointing to the main branch.
- B
B. Enable continuous integration triggers under the 'Classic Editor' without specifying the branch.
- C
C. Configure a GitHub connection in Azure Pipelines using OAuth or a GitHub App, ensuring PR events are enabled.
- D
D. Disable branch protection rules in GitHub to allow unrestricted pushes into the main branch.
Show answer and explanation
Correct answers: A, C
Explanation
To automatically trigger builds for every new pull request, you must both set the relevant trigger in the Azure Pipelines YAML (for example by using 'pr' triggers) and properly authenticate Azure Pipelines with GitHub (OAuth or a GitHub App) so that the PR events can be communicated. Refer to Microsoft Docs (https://docs.microsoft.com/azure/devops/pipelines/repos/github) for detailed steps on configuring the triggers and authentication.
- A. Correct.
A. Correct. By specifying 'pr: branches: include: - main' (or similar) in your pipeline YAML file, you instruct Azure Pipelines to trigger a build whenever there is a pull request targeting that branch. This is a main mechanism to enable PR-based builds.
- B. Incorrect.
B. Incorrect. Using the 'Classic Editor' without specifying the branch will not reliably capture pull request events. You must explicitly configure CI triggers for the correct branch or define these triggers in YAML for GitHub PRs.
- C. Correct.
C. Correct. Connecting Azure Pipelines to GitHub using OAuth or a GitHub App ensures that PR events (and other triggers) are accepted. Without properly configuring this connection, Azure Pipelines won�t be able to listen to PR events from GitHub.
- D. Incorrect.
D. Incorrect. Disabling branch protection rules removes important security and process controls. It does not guarantee a PR trigger for the build pipeline. In fact, branch protection is typically recommended to ensure code quality and best practices.