New website-deploy for every PR

Kristofer Tvedt Henrichsen 1 Reputation point
2020-03-31T08:40:16.383+00:00

Hei! We are a couple of developers working on the same webpage hosted on Azure as an app service, and we're wondering if it is possible to dynamically create a new test-website for every pullrequest that comes in? Our current worklfow consists of just autodeploying the latest PR to our test-environment (using azure pipelines/CI), but ideally we would want each active pull request to spin up a seperate instance of the web app. In other words, we want each pull request to create a new app service with a unique URL, for example:
pr-25.testpage.com
pr-99-testpage.com

I've looked trough much of the documentation on azure deployment center, but i cant find anything to help us in this scenario. Our project is written in c# using .Net Core 3.1 with react frontend. Any ideas :)?

Appreciate any help! Regards, Kristofer

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,629 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ryan Hill 24,731 Reputation points Microsoft Employee
    2020-03-31T23:29:18.653+00:00

    Hi @Kristofer Tvedt Henrichsen ,

    Perhaps you can elaborate on the need to have a new app service with each deployment because it's certainly an uncommon workflow. Nonetheless, I think you can achieve your goal by making use of ARM templates inside a PowerShell script. You can create your template where the build version of your CI build is a parameter to your CD. This parameter can be passed into your *.ps1 that will use it to create your app service in which resource group you want. Your script files can be kept inside the repo to make referencing them in the pipeline easier. This doc illustrates using yaml to define your pipeline and references a PowerShell script file. This blog post shows how to use a script file in a CI/CD pipeline with tasks. You can easily export your resources to get a template that you can modify to accept parameters from your pipeline.

    I hope this helps point you in the right direction.

    0 comments No comments

  2. Kristofer Tvedt Henrichsen 1 Reputation point
    2020-04-08T06:38:53.737+00:00

    Hi! Thanks for your reply @Ryan Hill . Currently we have 3 deployment slots on our web-app. Dev, QA and Production. In our normal workflow, after a developer has made changes he is satisfied with, he would create a pullrequest towards master in our Dev-environment. This will then automatically trigger a build and release pipeline that deploys this new version of our webapp to our Dev-environment. After testing, we would then merge the PR to master, and push the code changes to QA and Prod as well.

    But, the problem arises when multiple developers have big pull requests - and would want to test their features in the cloud at the same time. Only ONE branch/pr could be deployed to the Dev-slot at a single time - meaning that developers need to "reserve" the Dev-environment for testing. What we would ideally like, is that when a pull request is created towards master, the code would be built and deployed to a unique Pull-Request environment. Meaning that we dynamically have X development environemts, one for each active pull request. This would allow the master-Dev-environment to be stable, and all the changes made by different developers would live in their own PR-deployed environment.

    I guess it is similar to what is suggested here, but that guide is based on AKS. I wonder if it is possible to do this with azure web apps?
    https://devblogs.microsoft.com/devops/review-apps-in-azure-pipelines/