Getting blank page after Azure deployment - Web Api .Net 6.0

Marjan 20 Reputation points
2023-07-11T06:42:24.6466667+00:00

I'm trying to deploy my project on Azure. During the process I didn't get any error message, however, when I try to open the link I get blank page.

The application is working smoothly on my local machine, I'm not sure what could be the problem. I tried to deploy it several times. Any help is appreciated!

Application info: Web Api .Net 6.0

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,247 questions
{count} votes

Accepted answer
  1. JasonPan - MSFT 4,791 Reputation points Microsoft Vendor
    2023-07-11T09:04:49.3766667+00:00

    Hi @Marjan,

    You are trying to deploy .net 6 api project to azure. Now you are facing 404 error, it's expected behavior. You can try to check the /WeatherForecast endponit works or not. It should works normally.

    If you want to open the swagger page, we need to comment the condition in Program.cs ,like below

    // Configure the HTTP request pipeline.
    if (app.Environment.IsDevelopment())
    {
        app.UseSwagger();
        app.UseSwaggerUI();
    }
    

    to

    // Configure the HTTP request pipeline.
    //if (app.Environment.IsDevelopment())
    //{
          app.UseSwagger();
          app.UseSwaggerUI();
    //}
    

    Then we can open the swagger index page.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason Pan


6 additional answers

Sort by: Most helpful
  1. Marjan 20 Reputation points
    2023-07-11T09:01:35.88+00:00

    Update: the API endpoints are working, however I can't see swagger page.

    I add '/swagger/index.html' in the end of the link but still I can't see the page.

    0 comments No comments

  2. RevelinoB 2,775 Reputation points
    2023-07-11T09:05:04.31+00:00

    Hi Marjan,

    If the API endpoints are working but you're unable to access the Swagger page, it indicates that the issue is specifically related to the Swagger UI configuration or deployment.

    Here are a few steps to troubleshoot the problem:

    • Verify Swagger configuration: Ensure that the Swagger configuration in your ASP.NET Core application is set up correctly. Check the configuration code in your startup file (Startup.cs) to confirm that the Swagger services and middleware are properly registered.
    • Check the Swagger endpoint: By default, Swagger UI is usually available at the /swagger/index.html endpoint. However, this can be customized during configuration. Double-check the endpoint path for Swagger UI in your application.

    Verify Azure Web App deployment: Make sure that the Swagger UI-related files, such as the Swagger JSON and the Swagger UI assets, are being deployed to Azure Web App correctly. Check your deployment process and ensure that these files are included.

    Ensure correct Swagger endpoint URL: When accessing the Swagger UI page, verify that you're using the correct URL. It should be in the format: https://your-app.azurewebsites.net/swagger/index.html (replace your-app with your actual Azure Web App name).

    Check for errors in the browser console: Open the browser's developer tools and check the console for any error messages. It's possible that there may be JavaScript errors preventing the Swagger UI from loading properly.

    Test locally with Azure App Service emulator: To isolate any deployment-related issues, you can try running your application locally using the Azure App Service emulator. This allows you to test the deployment and Swagger UI functionality locally before deploying to Azure.

    Enable detailed logging: In your Azure Web App's "Configuration" section, under "General settings," set "Detailed error messages" to "On." This can help identify any potential errors or issues related to serving the Swagger UI files.

    Check the Azure Web App logs: In the Azure portal, navigate to your Web App and go to the "Log stream" or "Logs" section. Monitor the logs while accessing the Swagger UI to see if there are any error messages or exceptions related to serving the Swagger UI files.

    By following these steps, you should be able to identify the cause of the issue and troubleshoot the problem with accessing the Swagger UI.

    I hope this helps?

    0 comments No comments