Redeploy failed git deployment - azure-web-app-service

Occasionally, for whatever reason, when I deploy a commit via azure websites local git repo, it cannot find one of our remote repos (server down, whatever) and so it fails to retrieve certain nuget packages, causing the whole deployment to fail.
In this scenario, the only way I've found to force the deployment to execute again is to commit another change; this is no bueno. Is there a way to re-run a failed git deployment without triggering the auto deployment via a new commit?

Goto Azure Portal, Select the DEPLOYMENTS tab of your site. Select the failed deployment item and you should see the retry button on the bottom command bar. Try click it. You can also force deploy any successful items by selecting it and click redeploy button.

Related

Why doesn't Azure Pipelines pick up commit on GitHub?

We use Azure Pipelines for our CI/CD processes since a few weeks. The CI pipeline gets code from GitHub, builds, tests and creates a deploy package.
From the beginning I am quite certain that every commit got detected as intended, but recently that is not the case. Manual triggers and scheduled triggers work, but continuous integration does not.
What could be the causes for this?
In the pipeline, we checked the box for "continuous integration", and we use the recommended GitHup App to provide authorization. This is verified to work, we can see the authorized GitHub repos in the pipelines settings.
You can check if the github branch you committed to is included in the Branch filters. If it is not included. Click Add to add the branch.
Check if there is skip CI command(eg.[skip ci]) in commit message. See here for more information.
If CI trigger is not working even all the settings are correct. You can try below workarounds:
1,Disable the CI trigger, save, then re-enable it and save it again.
2,Clone your build definition. See below screenshot
3, Create a new build pipeline with the same trigger and settings.
If all above arenot working. You can go to this site to see if there is a server outage of azure devops.
We ended up changing how we connect from Azure Pipelines to GitHub. The recommended way is to install the Azure App in GitHub and connect using that in Pipelines. My experience is that it worked at first, but stopped working. I read somewhere that only the first connection works with webhooks, so maybe we tried it somewhere else or something that broke it. I ended up using a GitHub servic account to pull and listen for webhooks, and that works just as expected.

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.

Azure DevOps Build Pipeline - A failed build still gets deployed to Azure

I'm trying to create a CI/CD pipeline for an example prototype. Thus, I've started simple enough to test my infrastructure - I'm using an almost untouched boilerplate of ASP.NET Framework Web App (targeting 4.6.1). The steps I've completed are:
App is deployed to an Azure App Service.
Its version control is hosted with Azure DevOps.
A build pipeline with the following tasks has been created, set-up and tested if it executes (tasks and their order, come from a template):
Azure Deployment Options/Settings are bound to the repository DevOps, thus builds are also displayed in Azure, and should be deployed there if successful.
The Build Pipeline is bound to the correct repository inside DevOps
Builds get triggered by pushing to the master branch
The next step was to verify that a broken build, because of failed tests or any other reason is not deployed to production in Azure. I've created a failing test for this reason.
And this is where I'm left stumped. Builds do fail as expected and the "App Service Deploy" task is skipped, because the build tasks before it have a failure:
And yet those broken builds still get deployed to Azure and to production without even waiting for the pipeline to finish. I'm verifying that a change has actually happened with small visual updates.
Build started and finished in Azure as soon as a push occurs before the pipeline in DevOps is fully traversed (or even started, if finding an agent takes longer):
(DevOps still not finished):
What am I doing wrong here? Am I understanding the pipeline wrong? Have I missed a set-up step somewhere? I'm lost.
Edit: As asked by Josh, here's my trigger as well:
Edit 2.2 A bit more clarification of my deployment options in my App Service in Azure, related to Daniel's comments:
This turned out to be the issue.
This is the only option I'm allowed to choose when tying my deployment to DevOps. I'm not allowed to choose a pipeline, just a project and a branch. In a tutorial I've compared with, the settings are the same (at least in this menu), but the build does not get triggered from the repository, but expects the pipeline to reach the appropriate step first, which is why I haven't considered it to be the culprit. Is there some additional setting up, I've missed to do, to indicate that it must look for a pipeline, rather than fire straight away from branch changes?
The deployment you have set up in the Azure portal is tied to source control only, not your build definition. So every time you commit to source control, two things happen that are totally disconnected from each other and start in parallel since they listen to the same repository for changes:
A build fires off in the pipeline.
The Azure website is updated with the version you just pushed to source control, since its deployment options are bound to it.
Remove #2 and your problem will go away. You set the App Service you want updated in the pipeline, you don't need an additional hook in the App Service itself.

Azure-Web-sites: How to cancel a deployment?

I have an Azure Function App / Azure Website setup with continuous deployment from source-control.
This App has a custom deployment script that takes quite a bit of time to run. Occasionally I push out a change to git which was a mistake, and I want to cancel that one deployment (While still allowing future git pushes to cause a deployment).
Is there a PowerShell command I can run, or some option which will cancel my current deployment?
I was able to figure this out eventually, and figured I'd post it here. There is no "clean" way to do this, but there is a "hack".
Navigate to your SCM site:
[YOUR_WEBSITE].scm.azurewebsites.net
Click on "Process Explorer"
Find the process which is the current deployment and choose "Properties".
Scroll to the bottom of the page and choose "Kill"
VoilĂ , you've killed your deployment in the middle.
Just run this small az-cli command. It will stop/kill your current deployment.
az webapp deployment source delete --name MyWebApp --resource-group MyResourceGroup
Once it's done, you can try deploying your webapp again!
There's nothing simple as far as I know.
It's possible that deleting the deployment via kudu rest apis (https://github.com/projectkudu/kudu/wiki/REST-API#deployment) would achieve what you want, but I expect that that will fail during deployment / only delete metadata and logs about the deployment.
Also, cancelling a deployment could leave unwanted artifacts in the filesystem / corrupt your web app. It's probably best to modify your deployments so that you have a development branch and a release branch in order to set up a more robust CI scenario.
You can try to stop the web app.
Open the webapp in Azure portal
Click on Stop or Restart
This will stop active deployments,
Redeploy from VS Code.

Deploying Website on Azure using repository

I am using the repository way of hosting a website on Azure. The domain/url has been created and has also been connected to my Bitbucket repository. The problem is when I click the deploy button under the "Deployment Source" tab, All of the other indicators show that I am successful except for the last one. The last one has the red warning icon and reads "Running deployment command...". This error is in the way of being able to access my project on the internet.

Resources