Anyone having issues with using SQL Dependency in Azure Web Apps?

1

Trying to use SQL dependency in a .NET 4.7 Azure Web Application against an on premise SQL server (not an Azure SQL db) via a hybrid connection with SQL Authentication. Everything works running locally on dev system and in other environments within our network, but not when deployed to an Azure Web App Service.

When this code is called in the Global.asax.cs, Application_Start()

SqlDependency.Start("SomeConnectionString");

It throws the error :

[ArgumentException: connectionString]

System.Data.SqlClient.SqlDependency.Start(String connectionString, String queue, Boolean useDefaults) +493
MyWebApplication.Application_Start() +661

[HttpException (0x80004005): connectionString]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +517
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +185
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): connectionString]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +714

c#
azure
sqldependency
asked on Stack Overflow May 12, 2020 by Jesse Smith

1 Answer

1

Turns out this wasn't SQL dependency at all. The Azure Web App was attempting to pull connection strings from the web.config and was failing intermittently (which is another problem). Moving the connection strings to the app service configuration solved the issue.

answered on Stack Overflow May 14, 2020 by Jesse Smith

User contributions licensed under CC BY-SA 3.0