HealthCheck UI not able to pull the details when deployed using Azure Dev Spaces

0

I have developed asp.net core 3.1 based web api and implemented the HealthCheck and HealthCheckUI based on the documentation available at : https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks

Before implementing it in the original project I have developed a POC and it worked fine as expected.

Now I tried to do the same in the original project which is leveraging Azure Kubernetes services and deployed in Azure Dev Spaces.

Here goes my code :

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services.AddCustomHealthChecks(Configuration);
}

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
        app.UseEndpoints(builder =>
        {
            builder.MapHealthChecks("/health", new HealthCheckOptions()
            {AllowCachingResponses = false}).RequireCors(CorsPolicyName.AllowAny);
            builder.MapHealthChecks("/healthcheck", new HealthCheckOptions()
            {Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse}).RequireCors(CorsPolicyName.AllowAny);
        }    
        app.UseHealthChecksUI();
  }


public static IServiceCollection AddCustomHealthChecks(this IServiceCollection services, IConfiguration configuration)
{
    var cosmosDBServiceEndPoint = configuration.GetValue<string>("CosmosDBEndpoint");
    var cosmosDBAuthKeyOrResourceToken = configuration.GetValue<string>("CosmosDBAccessKey");
    var cosmosDBConnectionString = $"AccountEndpoint={cosmosDBServiceEndPoint};AccountKey={cosmosDBAuthKeyOrResourceToken};";
    var hcBuilder = services.AddHealthChecks();
    hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()).AddCosmosDb(connectionString: cosmosDBConnectionString, name: "CosmosDB-check", failureStatus: HealthStatus.Degraded, tags: new string[]{"cosmosdb"});


    services.AddHealthChecksUI();
    return services;
}

On deploying the above code in Azure Dev Space I am getting the below error:

An exception occurred while iterating over the results of a query for context type 'HealthChecks.UI.Core.Data.HealthChecksDb'.
      Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'near "(": syntax error'.
         at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
         at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
         at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
         at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
         at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
         at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
         at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()

Can anyone help me to know how to fix this issue?

azure-aks
c#-8.0
asp.net-core-3.1
azure-dev-spaces

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0