.Net core container app showing No webpage was found for the web address: https://xyzapp.azurewebsites.net/

Viewed 40

I am running .NET Core API on docker and it's working fine on my local machine as I create Azure devops pipelines it is not working on Azure app service showing error

No webpage was found for the web address: https://xyzapp.azurewebsites.net/swagger/index.html HTTP ERROR 404

When I build the image locally and push it to Azure app service using the same dockerfile it is then working fine.

Here are the error logs of api

08:45:46 WRN] Failed to determine the https port for redirect. [08:45:46 INF] HTTP GET / responded 404 in 162.0077 ms

Does anyone has idea what's wrong in it, locally build is running and by building Azure devops showing this error

1 Answers

You can test your webapi directly by postman or browser, it should be working fine.

And if your all steps in devops is correct, then you need check your Program.cs file (.Net6). If you are using other version, you need check Startup.cs file.

Then find the IsDevelopment condition, something like below.

if(app.Environment.IsDevelopment){
    app.UseSwagger();
    app.UseSwaggerUI();
}

Change it to

if(app.Environment.IsDevelopment){
    app.UseSwagger();
    app.UseSwaggerUI();
}else{
    app.UseSwagger();
    app.UseSwaggerUI();
}

I think that swagger is generally used for project cooperation or in development mode. The /swagger/index.html page is generally not provided in the production environment, which should be for security.

Related