question

KristoferTvedtHenrichsen-1123 avatar image
0 Votes"
KristoferTvedtHenrichsen-1123 asked ryanchill commented

New website-deploy for every PR

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-webappsazure-webapps-content-deployment
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ryanchill avatar image
0 Votes"
ryanchill answered

Hi @KristoferTvedtHenrichsen-1123,

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KristoferTvedtHenrichsen-1123 avatar image
0 Votes"
KristoferTvedtHenrichsen-1123 answered ryanchill commented

Hi! Thanks for your reply @ryanchill. 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/

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

One idea that comes to mind is using the ARM Template task. Create a template that will create a random app name concatenated with the pull request author. Use template to create and deploy the new ARM resource. From a pipleline standpoint, I would allow the build to be triggered by a set a branches, either feature/ or users/, something that will make it manageable and you're not having to update the pipeline often. Let me know if you run into any issues setting this up; I'll do my best to help you.


0 Votes 0 ·