I want to be able to create and deploy a web application when a feature branch is created from a linked Git repository in Azure Devops and then remove the site and files when the branch is closed.
Creating a new site is straightforward using calculated values to deploy to unique folders, but how would I start to trigger cleanup tasks when a feature branch is merged and closed no longer going to be used?
You can use a service hook to subscribe to the event "Pull request merge attempted". With the webhook you can send a notification to an http endpoint (for example an Azure function) that can host the cleanup logic:
When you subscribe to the
Pull Request merge attemptedan event of type git.pullrequest.merged is sent to the endpoint for the repositories that matches the criterias in the service hook trigger: