AZ-400: Designing and Implementing Microsoft DevOps Solutions
Configure Activity Traceability and Flow of Work
Demo Integrate Azure Pipelines and GitHub Actions
In this guide, you’ll learn how to trigger an Azure Pipeline automatically from a GitHub Action whenever you push code to the main
branch. By the end, you’ll have a seamless CI flow between GitHub and Azure DevOps.
1. Connect GitHub to Azure DevOps
- In your Azure DevOps project (e.g., SimpleWebAPI), navigate to Project Settings → GitHub Connections.
- Click Connect Your GitHub Account and authorize Azure DevOps to access your repos.
- Select the SimpleWebAPI repository and hit Save, then approve the installation in GitHub.
2. Generate a Personal Access Token (PAT)
You’ll need a PAT with permissions to queue builds. In Azure DevOps:
- Click your user icon → Personal Access Tokens → New Token.
- Give it a name, expiration date, and select scopes:
- Build (read & execute)
- Token administration (read & manage)
- Create the token and copy it immediately.
Warning
You will only see the PAT value once. Store it securely in your password manager.
3. Create an Azure Pipeline
- In SimpleWebAPI, select Pipelines → Create Pipeline.
- Choose GitHub and pick SimpleWebAPI. Approve the Azure Pipelines app if prompted.
- Opt for Starter Pipeline to get a minimal YAML template.
# azure-pipelines.yml
# Starter pipeline: build and deploy your code.
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
For more customization, see the Azure Pipelines YAML schema.
4. Configure an Agent Pool
If you use self-hosted agents:
- Go to Project Settings → Agent pools and note your pool name (e.g.,
KodeKloudCustomer
). - Update the
pool
block in your YAML:
# azure-pipelines.yml
trigger:
- main
pool:
name: 'KodeKloudCustomer'
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
Note
When targeting a self-hosted pool, remove the vmImage
setting. Jobs run on your specified agents.
Save and queue your pipeline. You should see a successful run:
5. Set Up the GitHub Action
- In your SimpleWebAPI GitHub repo, go to Actions → Set up a workflow yourself.
- This creates a blank file at
.github/workflows/main.yml
. Replace its contents with:
# .github/workflows/trigger-azure-pipeline.yml
name: Trigger Azure Pipeline
on:
push:
branches:
- main
jobs:
trigger-pipeline:
runs-on: ubuntu-latest
steps:
- name: Trigger Azure DevOps Pipeline
uses: azure/pipelines@v1
with:
azure-devops-project-url: ${{ secrets.AZURE_DEVOPS_PROJECT_URL }}
azure-pipeline-name: 'jeremykodekloud.SimpleWebAPI'
azure-devops-token: ${{ secrets.AZURE_DEVOPS_TOKEN }}
6. Configure Repository Secrets
In GitHub, go to Settings → Secrets and variables → Actions and add:
Secret Name | Value Example |
---|---|
AZURE_DEVOPS_PROJECT_URL | https://dev.azure.com/yourOrg/yourProject |
AZURE_DEVOPS_TOKEN | (your Azure DevOps PAT) |
Commit your workflow to main
. The GitHub Action triggers immediately, and you should see a corresponding run in Azure Pipelines.
7. Verify Continuous Integration
Every push to main
now triggers:
# Pull latest changes
git pull
# Make edits and commit
git add .
git commit -m "Fix typo in README"
git push
Watch the GitHub Action and Azure Pipeline execute in tandem—your CI process is fully automated!
References
Watch Video
Watch video content