When hosting .net core web app in azure my health checks cause the app to crash

0

I have added health checks using https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks;

All works fine on my local IIS but as soon as i push it to azure i get the below error that is found in the logs on azure.

[Error] Microsoft.EntityFrameworkCore.Query: 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 5: 'database is locked'.at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()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.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues, CancellationToken cancellationToken)at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable1.AsyncEnumerator.BufferlessMoveNext(DbContext _, Boolean buffer, CancellationToken cancellationToken)at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator2.MoveNextCore(CancellationToken cancellationToken) in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\Select.cs:line 106at System.Linq.AsyncEnumerable.AsyncIterator1.MoveNext(CancellationToken cancellationToken) in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\AsyncIterator.cs:line 98at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 5: 'database is locked'.at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()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.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues, CancellationToken cancellationToken)at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable1.AsyncEnumerator.BufferlessMoveNext(DbContext _, Boolean buffer, CancellationToken cancellationToken)at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator2.MoveNextCore(CancellationToken cancellationToken) in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\Select.cs:line 106at System.Linq.AsyncEnumerable.AsyncIterator1.MoveNext(CancellationToken cancellationToken) in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\AsyncIterator.cs:line 98at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)

This is causing the web app to crash hosted in azure.

Does any one have ideas of what could cause this issue, and a way to fix it?

the health checks i have registered are.

  services.AddHealthChecks()
            .AddCheck<ProjectHealthCheck>("Project Health Check")
            .AddUrlGroup(new Uri($"{healthCheckUri}/api/system/healthcheck"), name: "Enterpise Api Health Check")
            .AddMongoDb(this.Configuration.GetValue<string>("MongoDatabaseSettings:ConnectionString"));

Im guessing the cause is because of this ''database is locked'' but cannot find a soultion

sqlite
.net-core
asked on Stack Overflow Dec 12, 2019 by Hawkzey

1 Answer

1

I dont have enough rep to comment so posting as an answer but I'd start by making sure the deployment isn't readonly: In Azure configuration, ensure you don't have either of these entries WEBSITE_RUN_FROM_ZIP or WEBSITE_RUN_FROM_PACKAGE.

I'd then ensure that the app is "Always On" in the general settings part of the configuration and when you deploy the app I'd make sure to delete all files (this is a tickbox in the deploy settings if using visual studio).

Anyway, hope that helps.

answered on Stack Overflow Dec 12, 2019 by Josh

User contributions licensed under CC BY-SA 3.0