fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
564 stars 144 forks source link

Crash on Azure Functions with dacpac/SSDT provider: `extractModelXml` fails due to read-only filesystem. #743

Closed varon closed 2 years ago

varon commented 2 years ago

Describe the bug

Thanks for releasing 1.2.8. This let us get a little further with getting the SqlProvider running on Azure Functions. We are seeing a crash on loading a dacpac file with this, as it seems like the file system is read-only.

"Read-only file system"

Why are we even loading the .dacpac at all at runtime? Surely it should just default over to the regular SqlClient instead?

Full stacktrace/logs:

2021-08-09T14:53:29Z   [Critical]   [SqlDb]:Failed to create database context!!
2021-08-09T14:53:29Z   [Critical]   [SqlDb]:exn type: System.IO.IOException, msg: Read-only file system
Stacktrace:
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at FSharp.Data.Sql.Ssdt.DacpacParser.extractModelXml(String dacPacPath)
   at FSharp.Data.Sql.Providers.MSSqlServerSsdt.parseDacpac@80.Invoke(String x)
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at FSharp.Data.Sql.Providers.MSSqlServerProviderSsdt.FSharp-Data-Sql-Common-ISqlProvider-GetTables(IDbConnection con, CaseSensitivityChange _arg1)
   at <StartupCode$FSharp-Data-SqlProvider>.$SqlRuntime.DataContext.addCache@38-1.Invoke(Unit unitVar)
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at FSharp.Data.Sql.Runtime.SqlDataContext..ctor(String typeName, String connectionString, DatabaseProviderTypes providerType, String resolutionPath, String[] referencedAssemblies, String runtimeAssembly, String owner, CaseSensitivityChange caseSensitivity, String tableNames, String contextSchemaPath, OdbcQuoteCharacter odbcquote, SQLiteLibrary sqliteLibrary, TransactionOptions transactionOptions, FSharpOption`1 commandTimeout, SelectOperations sqlOperationsInSelect, String ssdtPath)

To Reproduce Steps to reproduce the behavior: This is complex to reproduce as it requires a lot of infrastructure: 1) Deploy to Azure Functions 2) Use a SSDT provider 3) Wire up the dacpac path correctly (thanks, 1.2.8) 4) Hit an endpoint that interacts with the database 5) watch the fireworks

Expected behavior World peace, F# replacing C#, and a non-crashing provider on Azure Functions.

Desktop (please complete the following information):