AZ-400: Designing and Implementing Microsoft DevOps Solutions

Work with Azure Repos and GitHub

Creating repository in Azure Repos

In this guide, you will:

  1. Create an Azure DevOps project
  2. Initialize and push a GitHub repo
  3. Connect GitHub to Azure Boards
  4. Configure an Azure Pipeline

1. Create an Azure DevOps Project

First, sign in to Azure DevOps and create a new project named CoolWebsite. We’ll use GitHub as the primary source control.

Note

If you prefer to host code in Azure Repos, add it as a remote:

git remote add origin https://<org>@dev.azure.com/<org>/CoolWebsite/_git/CoolWebsite

2. Initialize and Push to GitHub

a. Create the repository on GitHub

  • In GitHub, click New repository.
  • Name: CoolWebsite
  • Visibility: Private
  • Default branch: main

Warning

Ensure you have Git installed and authenticated with your GitHub account before proceeding.

b. Clone, add application code, and push

Clone the new repo locally:

git clone https://github.com/jeremykodekloud/CoolWebsite.git

Copy your application files into the CoolWebsite folder, then run:

ActionCommand
Stage changesgit add .
Commit changesgit commit -m "Initial commit"
Push to remotegit push -u origin main

Refresh the GitHub page to see your files.


3. Connect GitHub to Azure Boards

  1. In Azure DevOps, navigate to Project SettingsGitHub ConnectionsConnect to your GitHub account.
  2. Choose your organization (e.g., KodeKloud) and click Save.

The image shows a web interface for connecting GitHub repositories to Azure Boards, with a sidebar for project settings and a pop-up window indicating a saving process.

  1. You’ll be redirected to GitHub to install the Azure Boards app. Grant access only to the repositories you need:

The image shows a GitHub settings page for installing an Azure Boards app, with options for repository access and a "Danger zone" section for suspending or uninstalling the app.

  1. Back in Azure DevOps, confirm the connection under GitHub Connections:

The image shows a GitHub connection settings page in Azure DevOps, displaying a connection to a GitHub repository. The sidebar includes options for project settings, boards, pipelines, and more.


4. Set Up an Azure Pipeline

  1. Go to Pipelines and click Create Pipeline.

The image shows an Azure DevOps interface with a prompt to "Create your first Pipeline," featuring a button to initiate the process. The sidebar includes options like Overview, Boards, Repos, and more.

  1. Select GitHub, pick the CoolWebsite repo, and authorize the Azure Pipelines app.
  2. Choose the appropriate template (e.g., ASP.NET).

The image shows an Azure DevOps interface where a user is configuring a new pipeline, with options for different project types like ASP.NET and Xamarin.

  1. Replace the auto-generated YAML with this azure-pipelines.yml in your repo root:
trigger:
- main

pool:
  vmImage: 'windows-latest'
  name: 'KodeKloudCustomer'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
  1. Commit and push. Each push to main triggers a new build. Verify your YAML and commit history:

The image shows a GitHub repository page titled "CoolWebsite," displaying a list of files and folders with commit messages and details. The sidebar provides information about the repository, including languages used and suggested workflows.


You’ve successfully set up your CoolWebsite repository with Azure Boards and Pipelines. Explore Azure Boards and Azure Pipelines for more integrations.


Watch Video

Watch video content

Previous
Getting Started with GitHub