Azure automaticaly deploys update - azure

I have create an ASP.NET Core web app in Azure.
I have followed this documentation:
https://learn.microsoft.com/fr-fr/azure/app-service/quickstart-dotnetcore?pivots=platform-linux
Everything works, but I have create a new develop branch. Each time i push something in the branch, the deployment script is fired. Fortunately, it only deploys master branch on production. So if i have no merged files on master, it deploys the same files. But it might cut the website during a few seconds.
Is there a way to avoid the deployment when i am pushing something on develop branch ?
Thanks

Related

How to create app services for feature branches dynamically in Azure DevOps

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.
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.

Deploy each pull request to an app service with a unique URL

Is that possible?
It would be very convenient, to have all branches with an open PR deployed somewhere, where I can have a shareable link.
There are the PR-Branch Triggers, but AFAIK it can only deploy one branch to one environment at the time. And another PR update would just overwrite the state.
EDIT to clarify what I mean:
Each feature branch (or bugfix or whatever) of our webapp should be deployed to an app service (or whatever), so when we create the feature, we always have a link to share during development, in which our designers (or whoever) could find issues in early development. At another cloude storage provider, we had something like that and we would always receive a unique link after successful deployment.
I'm a bit late but working on this now. What I intend to do:
Pull request on selected feature branches triggers task 2
Task will create app services via Terraform (Link)
Use the 'app service deploy' task to push the artifact from that pull request to the new app service created in the prior task.
We'll see how it goes
If deploying each feature branch to an app service is what you are trying to achieve.
You can try below steps(Only for classic pipeline view):
1,In your CI build pipeline, Go to triggers page, add each of your feature branch to branch filters, So that each Pull request made to your feature branch can trigger a build.
2, in your CD release pipeline(Classic view), add different stages, each for an artifacts which built from feature branches:
3, for each stage, In the pre-deployment conditions page, add an artifacts filters to its corresponding feature branch. So that the artifacts from this specific feature branch will trigger to deploy its corresponding stage.
4, Change the settings and parameters of the tasks in each stage according to each feature branch. So that each app service deployed for each feature branch has its own settings and configurations,
5,Configure your app service deploy tasks in each stage.
With above steps done,each time when a new pull request is merged to the feature branch, the corresponding stage will be automatically triggered to deploy this pull request to the configured app service.

Disable automatic deploy on push on Azure Repo

I'm using Azure DevOps repository for a .NET Core web API and it happens that when I push the code into the repository, the application is immediately published to an Azure App Service. Since I'm using Azure Pipelines to execute some checks before publishing it, I need to disable this automatic deployment done by the push operation, but I didn't figure out how to do it. Is there a way to do it?
By accessing the Kudu service at xxxxxxxxxxxxxx.scm.azurewebsites.net I noticed that there's a folder under site/deployments/tool that contains two files:
- deploy.cmd
- deploymentCacheKey
If I manually remove them, they're automatically recreated once a push is done and the unwanted deployment operation happens.
I have other repositories that have the same folder but it's empty and when I push it remains empty and no unwanted deployment operation is done.
Do you have any suggestion about how to disable this behavior?
Edit
Added screenshots of continuous deployment trigger in the Release pipeline and the release history
Continuous deployment triggers
Release history
You can check if the Continuous deployment trigger is disabled in the lightning icon of Artifacts , as shown below.

Manual deployment from source control instead of automatic deployment?

I have two sites set up in Azure, a staging site and a production site.
Both sites are connected to the master branch of my git repository.
The stage site gets automatically updated when I commit a change to the master branch. What I'd like to do is have production set up so that it won't automatically be updated, but I can manually update it when I want to.
Basically so that changes will get pushed to stage, and when I'm ready for them to go to production, I can manually push them.
Is there a way to do that in Azure?
You have a couple of options:
Use a separate branch to deploy to production. For example a release branch. When you commit to the release branch, production will be deployed. This way you decide when will be deployed to production.
Another option, which is a bit more work. (especially if you have not done it before), but has it's advantages because of more control over the deployment:
Create a VSTS account in Azure. In the VSTS account create a project. Setup a build against your source to create artifacts which can be used in release management. Create a release which can deploy to Staging, and for example after a approval to production. (It's also possible to configure a swap here if you like, to release to producton)
For information about this:
https://www.visualstudio.com/en-us/docs/build/apps/aspnet/aspnet4-to-azure
https://www.visualstudio.com/en-us/docs/build/apps/cd/deploy-webdeploy-webapps

How to track deployment to Azure webapp in NewRelic?

Background info: I have set up Azure to automatically deploy code from develop branch (on Github) to dev-webapp when code is pushed to develop branch. When code is pushed to master branch, Azure deploys code from master branch to test-webapp and pre prod-deployment slot.
In Azure I'm using New Relic Appservice to monitor these apps. It works. What I want now is to notify New Relic when code is deployed to a webapp.
Quote New Relic:
To notify New Relic of a deployment, you can POST to https://api.newrelic.com/deployments.xml and add the API key as a header
To notify New Relic when code is deployed to dev and test, I could set up webhook in GitHub to run when code is pushed to develop-branch and master-branch. I have tested this, and it works. I feel like it is not optimal since the notification comes from Github, and not from Azure which is where the deployment actually takes place.
I also want to notify New Relic when the pre-prod deploymentslot is swapped with prod.
Is it possible? And what could be the best way to do this?
Maybe webjobs could be the soulution? This should be a webjob that only runs once after webapp is deployed and deployment-slot is swapped (for prod). I cannot find any information about setting up such job.
use powershell to swap slots and call new relic uri
https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/
I'm sorry I don't know New Relic but perhaps there is some similar solution as in application insights (why don't switch?), where you can specify version to be send:
http://blogs.msdn.com/b/visualstudioalm/archive/2015/01/07/application-insights-support-for-multiple-environments-stamps-and-app-versions.aspx (part: Version to Version comparisons)

Resources