App service windows container start error - azure-web-app-service

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

Related

Python 3.7 API hosting as Azure App Service for Windows

We have our Python API working with 3.6 however as of today Azure support Python3.7. We have our product on Windows Platform and the python3.6 works well in our On-Prem environment. We are hosting our product as Azure SaaS and need to use host Python API through Azure App Service. We have done code changes for Python3.7 API and hosted on Azure App service for windows platform but dont get any output. We have referred the below Azure documentation and attached is the error screenshot.
Anyone who has face similar issue and resolved it.
https://learn.microsoft.com/en-us/visualstudio/python/publish-to-app-service-windows?view=vs-2022
enter image description here
I have tried to reproduce the same by creating a sample BottleWebProject by using the python version 3.7.9 and deployed the web app to Azure App Service windows from Visual Studio successfully.
After creating the project in VS we have to add the virtual environment by right click on the Python environments -->Add Environment as shown in the below Images:
Then we can run in our local environment and test through VS(Run without debugging mode) and you will see the output if app runs successfully like in the below image.
Output:
Then you have to publish the webapp to the Azure by creating the App service, App service plan and click on publish in VS as shown in below image:
Output after publishing to Azure App Service Windows:

How FTP deploy .NET Core WebApp to Azure Linux App Service plan

I want do deploy code to Linux App service plan over FTP but I fail because I am missing a step how to "say to app service to use app DLL instead of default one".
Code is copied, I even uploaded test zip file and I can't download it, getting error 404 so how did Microsoft imagine to deploy code over FTP? I couldn't find any info in their documentation regarding this exact case.
I want to avoid using docker file, If this can't be done I'll simply switch to using Windows based App service plan.
In application setting screen of your WebApp mention the startup file name
dotnet

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 - docker container - take latest build after CI/CD

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

Azure app service docker container 'Service Unavailable'

I have followed the tutorials for building a .net core web application into a docker image, publishing to an azure container registry, and then I have setup my VSTS Release template to deploy the container to the app service.
This all appears to work, I can view my image in the container registry, and the deployment appears to succeed - but when navigating to the app service site, all I get is an HTTP 503 - Service unavailable.
The app service is started, I can see deployments in my file system via bash - so I wondered if I am missing something?
I do not have a 'startup' command in any of my templates, I wondered if it could be this?
The site works perfectly from VS2017, including debugging via docker, so it really is just a case of... how do I get the App Service to actually load and execute the image?
Thank you!
EDIT
Further to this, I have got access to the docker diagnostics logs which claim "image operating system "windows" cannot be used on this platform".
My base image is the microsoft/aspnetcore:2.0 image, which runs perfectly fine on my linux container in my development environment... but appears to not work in the Linux App Service?
Is the aspnetcore:2.0 base image not suitable for a linux app service?
I ended up resolving this week, hopefully the answer will help others.
When using VSTS Hosted build agents to produce images running off the docker base microsoft/aspnetcore:latest - unless you use the (Linux Preview) hosted build agent, you will get produced a windows container, which will not run on the linux app services.
Once I switched to using the hosted linux build agent, the container successfully loads, and my issue is resolved.
Another solution for the same error message:
Try microsoft/aspnetcore (without the tag/version :2.0) as image. If that doesn't work, check the docker logs as mentioned above and look for a solution based on the exact error (usually a missing dependency).

Resources