Articles in this section
Category / Section

ForgeFusion on Azure App service for Linux - Troubleshooting

Published:
Sometimes, Azure App Service for Linux encounters a few different issues during first-time deployment. Here's a breakdown of the critical errors that might crop up and possible steps to resolve them:

1. Container Exited:
  •    Error Message: `ERROR - Container forgefusion-backend for site forgefusion-server has exited, failing site start`
  •    This indicates that the container running your application is exiting unexpectedly.

2. HTTP Pings Failed:
  •    Error Message: `ERROR - Container forgefusion-backend didn't respond to HTTP pings on port: 8080, failing site start`
  •    The container isn't responding to health checks, which typically indicates that the application inside the container isn't starting correctly or listening on the expected port.

3. Dotnet Core Dump:
  •    Error Message: `dotnet "ForgeFusionBackend.dll" aborted (core dumped)`
  •    This suggests that there is a runtime error in your .NET application causing it to crash.

4. SQL Server Errors:
  •    Error Number: 208, State: 1, Class: 16
  •    This typically indicates that there is an issue with your SQL queries, such as referencing a non-existent table.

Steps to Debug and Resolve

1. Check Application Code:
  •    Ensure that your application is configured correctly to listen on the correct port (8080 in this case).
  •    Verify that there are no unhandled exceptions in your code, especially around the startup logic. Use logging to trace the startup sequence and identify where it fails.

2. Verify Database Configuration:
  •    The SQL Error 208 indicates an issue with your database schema. Double-check that all referenced tables and procedures exist and are correctly named.
  •    Ensure that your application has the necessary permissions to access the database.

3. Container Logs:
  •    Review the detailed logs from the container to identify any specific errors. You can access these logs via the URLs provided in your logs (e.g., `/home/LogFiles/2024_05_25_ln0xsdlwk0001Y3_default_docker.log`).

4. Local Testing:
  •    Run your application locally in a containerized environment to replicate the issue. This can help isolate whether the problem is with the Azure environment or your application.

5. Azure Configuration:
  •    Ensure your Azure App Service settings are correct, including environment variables, app settings, and connection strings.

6. Health Checks:
  •    Implement application-level health checks to ensure your application responds correctly to pings. This can involve adding a health check endpoint in your application.

7. Dependency Check:
  •    Verify all dependencies are correctly installed and compatible with your application. This includes any required libraries and runtime versions.

Example Code Check

Here’s a quick checklist for your .NET application:

- Program.cs:
  Ensure your `Main` method is correctly setting up the host and starting the application.
 
public static void Main(string[] args)
  {
      CreateHostBuilder(args).Build().Run();
  }

  public static IHostBuilder CreateHostBuilder(string[] args) =>
      Host.CreateDefaultBuilder(args)
          .ConfigureWebHostDefaults(webBuilder =>
          {
              webBuilder.UseStartup<Startup>();
          });

- Startup.cs:
  Verify that your application is correctly configured to use the necessary services and middleware.
public class Startup
  {
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddControllersWithViews();
          // Add other necessary services
      }

      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler("/Home/Error");
              app.UseHsts();
          }

          app.UseHttpsRedirection();
          app.UseStaticFiles();
          app.UseRouting();
          app.UseAuthorization();
          app.UseEndpoints(endpoints =>
          {
              endpoints.MapControllerRoute(
                  name: "default",
                  pattern: "{controller=Home}/{action=Index}/{id?}");
          });
      }
  }

By carefully reviewing the above aspects, you should be able to identify and resolve the issues causing your Azure App Service to fail. If problems persist, consider reaching out to Azure support with detailed logs for further assistance.
Access denied
Access denied