Preview Environments for Azure DevOps Pull Requests (Without GitHub)

How to get a live preview environment for every Azure DevOps pull request - service hooks, builds, isolated deployments, preview URLs and automatic cleanup - and why most deployment platforms only support GitHub.

Preview environments are one of the most loved features of modern deployment platforms: open a pull request, and a few minutes later there's a live copy of the app with your change, at its own URL. Reviewers click a link instead of pulling the branch.

There's a catch. Most platforms that offer this assume your code lives on GitHub - sometimes GitLab. If your company runs on Azure DevOps, as many European enterprises do, you are often left building it yourself.

This article explains how preview environments for Azure DevOps work, and what to look for in a platform that supports them.

How a preview environment works

Regardless of the Git provider, the flow is the same:

  1. A developer opens or updates a pull request.
  2. The Git provider notifies the deployment platform.
  3. The platform builds the branch into a container image.
  4. It deploys that image into an isolated environment - its own namespace, configuration and, if needed, its own database or volumes.
  5. It publishes a URL and reports it back on the pull request.
  6. On every new commit, steps 3-5 repeat.
  7. When the pull request is completed or abandoned, the environment is deleted.

The Azure DevOps specifics

Azure DevOps differs from GitHub in a few ways that matter for this flow.

Notifications come from service hooks. In Azure DevOps, you configure service hooks on a project to send events to a web endpoint - for example "Pull request created" and "Pull request updated". Azure DevOps service hooks authenticate to the receiving endpoint with HTTP Basic authentication rather than a signed secret header like GitHub's webhooks, so the receiving platform must handle that.

Pull request states are different. An open Azure DevOps pull request is "active", and closing one means it becomes "completed" (merged) or "abandoned". The platform must create environments for active pull requests and clean up for completed or abandoned ones.

Authentication for cloning. The platform needs to read the repository, typically through an OAuth connection or a personal access token, and must refresh tokens reliably - expired credentials are a common reason preview builds silently stop.

Reporting back. The preview URL should appear on the pull request, through a comment or a status, so reviewers find it without leaving Azure DevOps.

Monorepos and multi-service apps

Many enterprise repositories contain several services - a frontend, an API, workers - in one monorepo. A useful preview environment needs to:

  • Build only the services affected by the change, or all of them if needed.
  • Deploy the whole application so the preview actually works end to end.
  • Use the existing image for services that weren't changed.

Without this, previews for multi-service applications are either incomplete or slow.

Isolation and cleanup

Every preview should be isolated: its own namespace, its own routes, and - where the app writes data - its own volumes or database, so testing a pull request never touches staging data. Cleanup must be automatic. A preview system that leaves environments behind will slowly consume your cluster.

It also helps to set a limit on concurrent previews, so a busy week of pull requests can't overload the cluster.

Where NebuaCloud fits

NebuaCloud supports preview environments for Azure DevOps pull requests alongside GitHub, GitLab, Bitbucket and Forgejo. When an Azure DevOps pull request is opened or updated, NebuaCloud builds the changed services, deploys the whole application into an isolated preview on your own cluster, and gives it its own URL. When the pull request is completed or abandoned, the preview is removed.

Because previews run on your infrastructure, the code and test data in them stay in your environment too.

The takeaway

Preview environments aren't a GitHub-only luxury. With service hooks, reliable authentication, isolated deployments and automatic cleanup, Azure DevOps teams can have the same review workflow - ideally on a platform that handles the Azure DevOps details for them.

Availability in NebuaCloud

NebuaCloud currently supports Azure DevOps repository connections, service-hook-triggered pull request previews, per-service preview sources for multi-service applications, isolated preview routes and volumes, a limit on concurrent previews, and automatic cleanup when pull requests close.

Some combinations of Azure DevOps organization policies (for example restricted OAuth access) may require a personal access token instead of an OAuth connection.


Profile picture

Written with love by Nebuacloud, Private Cloud Infrastructure Automation Platform.