简体   繁体   English

任何人在使用 Azure Web 应用程序中的 SQL 依赖项时遇到问题?

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

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. 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.一切都可以在开发系统和我们网络中的其他环境中本地运行,但在部署到 Azure Web 应用服务时就不行了。

When this code is called in the Global.asax.cs, Application_Start()在 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 System.Data.SqlClient.SqlDependency.Start(字符串连接字符串,字符串队列,Boolean useDefaults)+493
MyWebApplication.Application_Start() +661 MyWebApplication.Application_Start() +661

[HttpException (0x80004005): connectionString] [HttpException(0x80004005):连接字符串]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +517 System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +517
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +185 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.HttpApplication.InitSpecial(HttpApplicationState state,MethodInfo[] 处理程序,IntPtr appContext,HttpContext 上下文)+168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): connectionString] [HttpException(0x80004005):连接字符串]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532 System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +714 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +714

Turns out this wasn't SQL dependency at all.原来这根本不是 SQL 依赖项。 The Azure Web App was attempting to pull connection strings from the web.config and was failing intermittently (which is another problem). Azure Web 应用程序试图从 web.config 中提取连接字符串并且间歇性失败(这是另一个问题)。 Moving the connection strings to the app service configuration solved the issue.将连接字符串移动到应用服务配置解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM