How do I deploy ASP.NET app to Azure Container? - OS version of image is not supported How do I deploy ASP.NET app to Azure Container? - OS version of image is not supported azure azure

How do I deploy ASP.NET app to Azure Container? - OS version of image is not supported


I had the same issue, ACI does not seem to be able to run all containers, only ones based on Windows 2016 (something to do with that being the host) so any Nanoserver based ones (the 1709 tells us that is what you are using) just don't work.


Here is the one paragraph I have found from Microsoft about it:

https://docs.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting#image-version-not-supported

Image version not supported

If you specify an image that Azure Container Instances cannot support, an ImageVersionNotSupported error is returned. The value of the error is The version of image '{0}' is not supported., and currently applies to Windows 1709 images. To mitigate this issue, use an LTS Windows image. Support for Windows 1709 images is underway.


Below is a working dockerfile that uses windowsservercore as the base image, so it will run on Azure Container Instances, but it also installs .NET Core 2.0 Runtime on that base image, so your core app will run.

You do need to download the dotnetcore installer from https://www.microsoft.com/net/download/dotnet-core/runtime-2.0.0 and add it to the root of your project, then set its Properties to have a build action of Content, that way it will get copied to the Docker container while its building it so it can be installed, but don't worry, it then gets deleted before the image is completed, so your image will not grow by much:

FROM microsoft/windowsservercore AS baseWORKDIR /appEXPOSE 80FROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS buildWORKDIR /srcCOPY mysolution.sln ./COPY myproject/myproject.csproj myproject/RUN dotnet restore -nowarn:msb3202,nu1503COPY . .WORKDIR /src/myprojectRUN dotnet build -c Release -o /appFROM build AS publishRUN dotnet publish -c Release -o /appFROM base AS finalWORKDIR /appCOPY --from=publish /app .#Install .NET CoreRUN dotnet-runtime-2.0.0-win-x64.exe /quiet /install#Tidy up by removing the installerRUN Del dotnet-runtime-2.0.0-win-x64.exeENTRYPOINT ["dotnet", "myproject.dll"]


Read the other answers about which base image to use, then come back here for the most efficient way of making your dotnet core container.

If you are having trouble getting the dotnet core runtime to install, you don't need to. You could set the publish to include all the dlls it needs so it is in standalone mode, then you don't need dotnet core installed at all.

I find that makes a smaller container image. Here is a working Dockerfile, the main difference is the lines:

RUN dotnet build -r win10-x64 -c Release -o /appRUN dotnet publish -c Release -r win10-x64 -o /app

which forces it to only be built for win10-x64.

FROM microsoft/windowsservercore AS baseWORKDIR /appFROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS buildWORKDIR /srcCOPY mySolution.sln ./COPY myProject/myProject.csproj myProject/RUN dotnet restore -nowarn:msb3202,nu1503COPY . .WORKDIR /src/myProjectRUN dotnet build -r win10-x64 -c Release -o /appFROM build AS publishRUN dotnet publish -c Release -r win10-x64 -o /appFROM base AS finalWORKDIR /appCOPY --from=publish /app .ENTRYPOINT [ "powershell.exe", "c:\\app\\init.ps1" ]

Then, because standalone mode in core creates an actual exe file instead of a portable dll, you need to have that ENTRYPOINT line on the bottom of the Dockerfile, and also create a powershell script, called init.ps1 which only needs one line in it, and the & at the beginning is important:

& "c:\app\myProject.exe"

Also set the ps1 file to be Content, so it gets copied to the root of your published folder.

With this your container should be smaller than ever before, and also will actually run!


A rep from Microsoft told me that Azure Container Instances do not support Windows Containers. This is something they are working on, but it's not available yet. I can't find any documentation that states this, but it appears to be true. I'm reading all kinds of stuff that says you can take your existing applications and run them in a container, but what they don't tell you is that, at least right now, you have to use Azure Service Fabric. It's the only way to run Windows Containers in Azure.