How to build Blazor Server Web App in Windows container and Deploy to Windows App Service?

Siegfried Heintze 1,906 Reputation points
2023-01-05T04:08:52.523+00:00

Background:
I see that windows containers (but not linux containers) support the auto instrumentation feature for .NET core.. I would like to deploy a windows docker container of my Blazor server app to test out the auto-instrumentation feature.

Code:
These commands seem to be working except for the last one.

export name=qsusdfsd12o  
export PLAN=${name}-plan  
export WEB=${name}-web  
export REPO=${name}-repo  
export IMAGE=${name}-image  
export RUNTIME="DOTNET:6.0"  
export ACR_SKU=Basic  
az acr create --resource-group $rg --name $REGISTRY  --sku $ACR_SKU --admin-enabled true  
az appservice plan create --name $PLAN  --resource-group $rg  --hyper-v --sku P1V3  
az acr build -g $rg --image $REPO/$IMAGE:v1 --registry $REGISTRY --file Dockerfile .  
az webapp create  --name $WEB --resource-group  $rg    --runtime $RUNTIME --plan $PLAN --deployment-container-image-name $REGISTRY.azurecr.io/$REPO/$IMAGE -s $USERNAME -w $PASSWORD  

Errors:
I'm getting this error on the last line:

ERROR: The parameter WindowsFxVersion has an invalid value. Unexpected exception while validating OS and version. Image: qsuwc712oreg.azurecr.io/qsuwc712o-repo/qsuwc712o-image:latest. Error Response: NotFound. Request: https://qsuwc712oreg.azurecr.io/v2/qsuwc712o-repo/qsuwc712o-image/manifests/latest. AuthType UserName. Response: NotFound. Request: https://qsuwc712oreg.azurecr.io/v2/qsuwc712o-repo/qsuwc712o-image/manifests/latest. AuthType UserName  

More Code: Dockerfile:

Here is the docker file generated by Visual Studio when I specified that I wanted a windows deployment:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base  
WORKDIR /app  
EXPOSE 80  
EXPOSE 443  
  
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build  
WORKDIR /src  
COPY ["BlazorSvrGitPlay.csproj", "."]  
RUN dotnet restore "./BlazorSvrGitPlay.csproj"  
COPY . .  
WORKDIR "/src/."  
RUN dotnet build "BlazorSvrGitPlay.csproj" -c Release -o /app/build  
  
FROM build AS publish  
RUN dotnet publish "BlazorSvrGitPlay.csproj" -c Release -o /app/publish /p:UseAppHost=false  
  
FROM base AS final  
WORKDIR /app  
COPY --from=publish /app/publish .  
ENTRYPOINT ["dotnet", "BlazorSvrGitPlay.dll"]  

Questions:

  1. Should this VS generated dockerfile be identical to the linux version? I expected them to be different. When I had VS add docker file support, I selected windows: 277225-image.png
  2. What is the cheapest appservice plan sku for windows containers?
  3. Do I have the correct switches for my app service plan for a windows container?
  4. Please guide me in correcting the error I'm getting regarding WindowsFxVersion.

Thanks!

Siegfried

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,177 questions
0 comments No comments
{count} votes

Accepted answer
  1. VenkateshDodda-MSFT 23,686 Reputation points Microsoft Employee
    2023-01-06T05:30:00.29+00:00

    @Siegfried Heintze Thank you for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    The Runtime value "DOTNET:6.0" that you are passing to the az webapp create cmdlet is not valid for windows-based app service plan. If you want to deploy webapp with runtime as dotnet 6 on Windows based /windows-based container app service plan, then your runtime value should be 'dotnet:6'.

    If you want to know more about the list of runtime version that are supported by specific Linux based and windows-based app service plan you can pull them by running this az webapp list-runtimes cmdlet from the CLI

    276781-image.png

    1. Should this dockerfile be identical to the linux version? I expected them to be different.
      Ans: *Based on my understanding yes, the docker file will be different for Linux and Windows based containers because they were built from different base images. *
    2. What is the cheapest appservice plan sku for windows containers?
      Ans: App service support deploying custom containers starting from Free tier app service plan. refer to this sample documentation on deploying custom container in free tier app service plan
    3. Do I have the correct switches for my app service plan for a windows container?
      Ans: Yes, the cmdlet that you are using will create p1v3 SKU windows container app service plan. For more information refer to the az appservice plan create cmdlet documentation
    4. Please guide me in correcting the error I'm getting regarding WindowsFxVersion.
      Ans:Pass the runtime value as 'dotnet:6' * instead of "DOTNET:6.0"*

    Feel free to reach back to me if you have any further questions on this,


1 additional answer

Sort by: Most helpful
  1. Siegfried Heintze 1,906 Reputation points
    2023-01-09T04:07:34.763+00:00

    Problem fixed! I added "--platform widows" to the "az acr bulid" command...

    AND

    --runtime 'dotnet:6' was the other part of the solution.

    I guess Visual Studio correctly generated the Dockerfile after all and it is indeed identical to the linux version (so why did they need to prompt me for windows or linux?)

    Thank you VenkateshDodda


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.