4

I'm working on an API in core3.1. We have a build pipeline that builds and unit tests any change for any branch. And release pipelines for development and master branches. These deploy to designated app services in Azure.

Now we would like a release pipeline for feature branches. So what we want is a pipeline that can dynamically created app-services per feature branch and deploy to that app service. And preferably dynamically delete the app-service when the branch is deleted.

Just to clarify, the proces how we would like it:

a developer creates feature branch and pushes it > 
the build pipeline builds it > 
an app service gets created automatically > 
stuff gets deployed to that app service > 
developers work on the branch and changes get build and deployed to the app service like normal > 
at some later point a developer deletes branch > 
app service gets deleted automaticcaly

Is there any way to accomplish this? Maybe there is a standard way? Feature branches are located in a subfolder, e.g. "feat/feature-branch-name". I'm fairly new to Azure and DevOps. Any help is appriciated. Thanks in advance.

Martijn
  • 739
  • 9
  • 26
  • 2
    How about an ARM template with necessary parameters that you get from e.g. the branch name? This would only take care of creation though, not deletion. – juunas Feb 24 '20 at 10:26
  • I will look into it. I should clarify though I'm fairly new to Azure DevOps. – Martijn Feb 24 '20 at 10:30
  • I looked into ARM templates and it's kind of a lot to dive into with just hopes of it giving me a solution. Does anybody have a more concrete idea to help me? I cannot be the first person who wants to do have such a solution. – Martijn Feb 24 '20 at 12:33
  • 1
    True.. It might be a bit over-kill for that. A script with az CLI or Azure PowerShell could do it easier. Still doesn't address the removing part though. I suppose some kind of scheduled job running somewhere could clean up those unused apps? – juunas Feb 24 '20 at 12:34
  • removing is not a must have. – Martijn Feb 24 '20 at 12:43

1 Answers1

2

You should follow the practice of Infrastructure as Code (IaC) and use ARM templates in your pipeline to create/update/delete your Azure resources. You can also use the built-in tasks available in Azure DevOps to deploy your ARM templates.

Hugo Barona
  • 1,303
  • 9
  • 21
  • The YAML snippet of this task looks a bit big, but in case you struggle to configure the YAML of your task, just use the classic editor and it is pretty straightforward. You should be fine with that, and following the best practices, that is the most important part :) – Hugo Barona Feb 24 '20 at 13:41
  • I asked a colleague and he wil take care of the ARM stuff while I work on the pipeline itself. Thanks for the help to both of you! – Martijn Feb 25 '20 at 07:08
  • Sorry, I thought I did that. I use a dark mode extention (dark night mode) for chrome that makes the gray and green checkmark both the same color. So I can only see the difference when i turn the extention off. – Martijn Feb 27 '20 at 07:51