Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open database file (when deployed to IIS) #181

Closed
DanielBakalar opened this issue May 14, 2019 · 4 comments
Closed

Unable to open database file (when deployed to IIS) #181

DanielBakalar opened this issue May 14, 2019 · 4 comments

Comments

@DanielBakalar
Copy link

When testing locally everything seems to work:

  • on /healthz, I get a JSON response and
  • on /hc-ui, I get a nice view of the checks.

However, when I deploy to IIS on a local test site, I get this message on both endpoints:

An error occurred while starting the application.
AggregateException: One or more errors occurred. (SQLite Error 14: 'unable to open database file'.)
System.Threading.Tasks.Task.Wait(int millisecondsTimeout, CancellationToken cancellationToken)

SqliteException: SQLite Error 14: 'unable to open database file'.
Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(int rc, sqlite3 db)

AggregateException: One or more errors occurred. (SQLite Error 14: 'unable to open database file'.)
System.Threading.Tasks.Task.Wait(int millisecondsTimeout, CancellationToken cancellationToken)
Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddHealthChecksUI(IServiceCollection services, string databaseName, Action<Settings> setupSettings)
Holidays.Project.Orchestrator.Api.ServiceCollectionExtensions.ConfigureHealthChecks(IServiceCollection services) in ServiceCollectionExtensions.cs
+
            services.AddHealthChecksUI();
Holidays.Project.Orchestrator.Api.Startup.ConfigureServices(IServiceCollection services) in Startup.cs
+
            services.ConfigureMvc()
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

So next I tried to comment out this line:
services.AddHealthChecksUI();
Now the /healthz endpoint returns a proper response, however the /hc-ui returns the usual UI, but the message in the title.

What am I missing here?

@unaizorrilla
Copy link
Collaborator

Hi @DanielBakalar

HealthChecksUI use SQLite to store healthchecks results on a healthchecksdb file. Can you ensure that the IIS process can write on the site path?

You can also modify the healthchecksdb path file, check HealthCheckDatabaseConnectionString

https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/samples/HealthChecks.UIAndApiCustomization/appsettings.json

@unaizorrilla
Copy link
Collaborator

I close this because no response!

@ranouf
Copy link

ranouf commented Oct 1, 2019

Hi,

In local, every thing works fine, but I publish the webapp on Azure I got an issue:

2019-10-01 17:14:48.829 +00:00 [Information] Microsoft.EntityFrameworkCore.Infrastructure: Entity Framework Core 2.2.6-servicing-10079 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: None
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]An error occurred using the connection to database 'main' on server 'D:\home\site\wwwroot\healthchecksdb'.Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)at Microsoft.Data.Sqlite.SqliteConnection.Open()at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
Unhandled Exception:
2019-10-01 17:14:53.028 +00:00 [Error] Microsoft.EntityFrameworkCore.Database.Connection: An error occurred using the connection to database 'main' on server 'D:\home\site\wwwroot\healthchecksdb'.Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'.at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)at Microsoft.Data.Sqlite.SqliteConnection.Open()at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
System.AggregateException: One or more errors occurred. (SQLite Error 14: 'unable to open database file'.) ---> Microsoft.Data.Sqlite.SqliteException: SQLite Error 14: 'unable to open database file'.

Following your suggestion, I updated the HealthCheckDatabaseConnectionString properties to Data Source=%APPDATA%\\wwwroot\healthchecksdb

My thinking about this probleme is because the webapp doesnt have the permission to create healthchecksdb.

Is there someone who had the same issue and found a way to fix it?

Thanks

@ranouf
Copy link

ranouf commented Oct 1, 2019

So the problem is clearly due to missing permissions. I dont know to change it on Azure easily. So I added healthchecksdb in the git repository, which is, in my mind, something wrong because the file changes at each commit.

So, I m still looking for a clean solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants