Azure app service - docker container - take latest build after CI/CD - azure

Through VSTS we have created CI/CD pipeline for a project, in which the end product is a docker image, which will be placed in a azure container registry.
In the azure app service, we have a linux container based service plan, which hosts the above placed latest image.
However, in the docker container, although we have enabled continuous deployment, the latest version is not taken, it is hosting the same older version of image.
How to deploy the latest docker image in app service container ?

Azure Container Registry webhooks can be used to automatically update your application running on Azure App Services that run your container applications.
Setup your image to deploy to your Azure Web App on Linux as per the instruction at https://learn.microsoft.com/en-us/azure/app-service-web/app-service-linux-using-custom-docker-image#how-to-use-a-docker-image-from-a-private-image-registry
In the App Settings section of your Web Application, add an app setting called DOCKER_ENABLE_CI with the value true.
Create a web hook in your registry and provide the docker callback uri which is of the form https://:#.scm.azurewebsites.net/docker/hook
https://:#.scm.azurewebsites.net/docker/hook
E.g. https://github.com/sajayantony/appservicedemo

Related

App service windows container start error

I've an asp.net core app that I want to run as windows container inside Azure app service.
The app uses PowerShell 5.1 and I'm not using mcr.microsoft.com/dotnet/aspnet:6.0, but building it as self contained. Snippets of the docker file are:
FROM mcr.microsoft.com/windows/servercore:ltsc2019 AS base
....
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
.. -c Release -o /app/publish --self-contained --runtime win-x64
...
and then
FROM base AS final
ENTRYPOINT ["App.exe"]
The docker file is used to correctly build and push to ACR from azure devops pipeline, but when running the image in App Service it says:
Unable to start container. Error message: Index was outside the bounds of the array
I've also tried couple of other base images:
FROM mcr.microsoft.com/dotnet/aspnet:6.0-windowsservercore-ltsc2019 AS base
and
FROM mcr.microsoft.com/dotnet/runtime:5.0-windowsservercore-ltsc2019 AS base
and they give same error.
I suspect it's because the image is not supported in app service.
Running locally on Windows 10 laptop is fine.
Does anyone know what windows images does app service support?
When we are creating an App service its create an image itself which is auto generated
If you want to configure custom image please refer this Microsoft Documentation:Configure a custom container for Azure App Service
As its failing while start the App service in windows container please check your console logs by Go to Advance Tools > Kudu console
For more information please refer the below links
MS Q&A:- Diagnose container start issues in Azure App Service for Linux & Azure App Service using a Windows container Failing and restarting
Troubleshooting Windows container in Azure app service
SO THREAD: Azure web app for container - failed during startup

How to automate Azure web app deployment to pick latest image from azure container

An Azure container registry is setup with a repository.
The Azure WebApp is published with Source specified as the container and the docker image tag is selected in the dropdown.
Using Jenkins the new build is made and the docker image is pushed to container repository in Azure.
But how to ensure the webapp automatically picks the latest image to be deployed.
Currently from the web app's deployment center we need to select the image and the latest pushed tag manually.
Locate your App Service, click Deployment Center, in the Settings tab, enable Continuous Deployment.
Documentation

Create a pipeline on azure devops to deploy a docker container on azure app service?

I have a docker image in my Azure Container Registry and a Web App For Containers(Linux). Now, I want to create a release pipeline which should be able to deploy that container for Azure Container Registry to Web App For Container. I know I can do this manually but I need to Automate this process through Azure DevOps.
I was trying to make a release pipeline to deploy docker image on Azure web app for container and I made that pipeline by following this tutorial.
https://learn.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-docker-webapp?view=azdevops&viewFallbackFrom=vsts
I hope this can help others as well. Thank you

Azure App service with or without docker

I have some experience in using azure app services without docker. I did worked on k8 with docker. Now I am seeing an option to deploy containers in azure app services. As per my understanding app services internally use container and orchestration engine. Now someone can explain why this new docker option in azure app services? How it is going to help? When to use this option? Why I should bundle it as docker(extra effort eventhough it trivial)?
Azure App Service on Linux (Web App with built-in images)
The built-in image option running on Linux is an extension of a current Azure App Service offering, catering to developers who want to use FTP or GIT, deploy .NET Core, Node, PHP or Ruby applications to Azure App Service running on Linux
All of the built-in Docker images are open sourced on GitHub and available on DockerHub
Now someone can explain why this new docker option in the azure app
services?
Web App for Containers is catered more towards developers who want to have more control over, not just the code, but also the different packages, runtime framework, tooling etc. that are installed on their containers.
Customers of this offering prefer to package their code and dependencies into containers using various CI/CD systems like Jenkins, Maven, Travis CI or VSTS, alongside setting up continuous deployment webhooks with App Service.
This way you can easily deploy and run containerized applications that scale with your business.
How it is going to help?
This will make sure that the environment that you use locally, is
exactly the same as the one in the cloud.
Just pull container images from Docker Hub or a private Azure
Container Registry and Web App for Containers will deploy the containerized app with your preferred dependencies to production in seconds.
Automate and simplify your container image deployments through
continuous integration/continuous deployment (CI/CD) capabilities
with Docker Hub, Azure Container Registry, and Visual Studio Team
Services
Automatically scale vertically and horizontally based on application
needs. Granular scaling rules are available to handle peaks in
workload automatically while minimizing costs during off-peak times
When to use this option?
If you are so passionate/familiar with Docker/container then you can
use the Azure App service with the container.
If you are planning to host all your container in ACS(Azure Container
Service)/GitHub Repository then this service might be useful
You can refer to this blog for more details

Azure Web App for containers CI with Azure Container Registry

I'm having an issue with Azure Container Registry CI with my Azure Web App for Containers. It seems that the web hook between them has broken.
I've tried turning the CI within the Docker settings on the Web App however this fails and also tried creating a web hook from the Azure Container Registry however it says my container registry isn't managed but doesn't give me the option to upgrade it to one.
Webhooks are not available in the classic SKU and you need to migrate for this. For CI you need to enable a webhook with the publishing creds which can call into the App service scm endpoint which can restart and repull.

Resources