I am using an apple m1. I have a basic dotNet 8 web api that works on my local docker
Program.cs
var builder = WebApplication.CreateBuilder(args);
var port = Environment.GetEnvironmentVariable("PORT") ?? "80";
builder.WebHost.UseUrls($"http://*:{port}");
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddControllers();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.MapControllers();
app.Run();
DockerFile
# build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
# copy csproj and restore dependecies
COPY *.csproj ./
RUN dotnet restore
# Copy others files and build
COPY . ./
RUN dotnet publish -c Release -o out
# run
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
EXPOSE 80
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "BgxApi8.dll"]
It works on local docker
docker build -t bgxapi8 .
docker run -p 80:80 bgxapi8
GET {{baseUrl}} -> "It works"
I try to make it run on an azure web app through an Azure Container Registry I create an Azure Container Registry named bgxapi8container I push my local docker
docker tag bgxapi8:latest bgxapi8container.azurecr.io/bgxapi8:latest
docker push bgxapi8container.azurecr.io/bgxapi8:latest
Then from the interface I create a web app with options : Os : Linux Publish : Container Docker Option : Unique container Image source : Azure Container Registry Registry : bgxapi8container Tag : latest Start Command : nothing
When I try to reach the root of the api I have this error message: "( Application Error If you are the application administrator, you can access the diagnostic resources."
If I look at the logs , I have this
... 2023-12-02T09:02:39.420Z INFO - e194839a3db8 Pull complete 2023-12-02T09:02:40.160Z INFO - Digest: sha256:1ac77a5b131c17b141f23e7fe360eb92d9d2d405c5e4783b23261c8f49d031c2 2023-12-02T09:02:40.160Z INFO - Status: Downloaded newer image for bgxapi8container.azurecr.io/bgxapi8:latest 2023-12-02T09:02:40.165Z INFO - Pull Image successful, Time taken: 16 Seconds 2023-12-02T09:02:41.162Z INFO - Starting container for site 2023-12-02T09:02:41.162Z INFO - docker run -d --expose=80 --name bgxapi8_0_d872b733 -e WEBSITE_USE_DIAGNOSTIC_SERVER=false -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=bgxapi8 -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=bgxapi8.azurewebsites.net -e WEBSITE_INSTANCE_ID=d48e7722c44716b2d3b260fd39937cd26b4df2c1aad200418e83e1648d9c8bd5 bgxapi8container.azurecr.io/bgxapi8:latest 2023-12-02T09:02:41.162Z INFO - Logging is not enabled for this container. Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here. 2023-12-02T09:02:43.219Z INFO - Initiating warmup request to container bgxapi8_0_d872b733 for site bgxapi8 2023-12-02T09:02:43.244Z ERROR - Container bgxapi8_0_d872b733 for site bgxapi8 has exited, failing site start 2023-12-02T09:02:43.249Z ERROR
- Container bgxapi8_0_d872b733 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging. 2023-12-02T09:02:43.280Z INFO - Stopping site bgxapi8 because it failed during startup.
Do you know what is the issue and how to solve it please?
You answered your question when you mentioned that you're building the image on an Apple M1. This results in an image that can run on ARM platforms and currently, App Service only supports AMD64.
On a M1 Mac, you can build multiarch containers using Buildx. This way, you can build an AMD64 version of your container that you'll be able to deploy on Container Apps. Documentation
Another option is to build the container image using Azure Container Registry. Documentation