I have a website hosted in an Azure app service, which connects to a SQL Server DB hosted (serverless) on Azure.
- When I set the Azure SQL firewall Connection Policy to "Proxy" (https://learn.microsoft.com/en-us/azure/azure-sql/database/connectivity-architecture)everything works as expected.
- When I set it to "Redirect" it works for read-only queries but fails on inserts and updates with the message, "An existing connection was forcibly closed by the remote host" and an obscure HResult (-2146232060). Stack trace below.
- When set to "Default" it fails the same way, but it works from my locally-hosted version of the site (as expected, since that scenario apparently defaults to Proxy).
Per the link above, I would prefer to get Redirect working. I see the bullet points beginning with "Allow outbound communications..." but I'm not sure (A) how to do that in an app service and (B) whether it is relevant here anyway. This seems like one of those things that ought to just work when you set the SQL server firewall to allow access from Azure services, but alas.
Details that may or may not be relevant:
- The web app is .NET 5.0, F#, built on the SAFE Stack.
- SQL connectivity is provided by F# SqlDataProvider
- SQL setup doesn't have to be serverless, if that's the problem
- As promised, full stack trace gobbledygook:
{"HelpLink.BaseHelpUrl":"https://go.microsoft.com/fwlink","HelpLink.EvtID":"10054","HelpLink.EvtSrc":"MSSQLServer","HelpLink.LinkId":"20476","HelpLink.ProdName":"Microsoft SQL Server","SqlError 1":"System.Data.SqlClient.SqlError: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)"},"Errors":null,"ExceptionMethod":null,"HResult":-2146232060,"HelpURL":null,"InnerException":{"ClassName":"System.ComponentModel.Win32Exception","Data":null,"ExceptionMethod":null,"HResult":-2147467259,"HelpURL":null,"InnerException":null,"Message":"An existing connection was forcibly closed by the remote host.","NativeErrorCode":10054,"RemoteStackIndex":0,"RemoteStackTraceString":null,"Source":null,"StackTraceString":null,"WatsonBuckets":null},"Message":"A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)","RemoteStackIndex":0,"RemoteStackTraceString":null,"Source":"Core .Net SqlClient Data Provider","StackTraceString":" at Microsoft.FSharp.Linq.QueryModule.CallGenericStaticMethod@374.Invoke(Tuple2 tupledArg) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\Query.fs:line 379 at Microsoft.FSharp.Linq.QueryModule.clo*anonymous user*-18.Microsoft.FSharp.Linq.ForwardDeclarations.IQueryMethods.Execute[a,b](FSharpExpr
1 q) in D:\workspace_work\1\s\src\fsharp\FSharp.Core\Query.fs:line 1928 at RoundTable.Data.SqlDataProvider.updateKisPlanIndividualResult@455.Invoke(Object context) at RoundTable.Data.SqlDataProvider.runWritableQuerya at RoundTable.Data.SqlDataProvider.runWritableQueryResult@107.Invoke(FSharpFunc2 f) at RoundTable.Validation.ErrorRecordModule.runWithErrorCatchingResult[a,b](FSharpFunc
2 f, a x)","WatsonBuckets"