间歇性IIS/Azure错误

间歇性IIS/Azure错误,iis,azure,web-config,Iis,Azure,Web Config,我有一个在Azure VM上运行的web应用程序。它是一个代码库,多个数据库。基于web.config中的appsettings(基本上是localhost或production),它知道要使用哪个数据库 就在最近,我做了一个简单的更新,并将代码推送到服务器上。我使用git将文件从repo拉到服务器,然后将dll从本地开发机器复制到服务器。这不是最好的,但现在已经奏效了 自从上次更新以来,我一直遇到间歇性的数据库连接错误(与我推送的udpates无关)。根据我收到的错误,应用程序正在查找错误的数

我有一个在Azure VM上运行的web应用程序。它是一个代码库,多个数据库。基于web.config中的appsettings(基本上是localhost或production),它知道要使用哪个数据库

就在最近,我做了一个简单的更新,并将代码推送到服务器上。我使用git将文件从repo拉到服务器,然后将dll从本地开发机器复制到服务器。这不是最好的,但现在已经奏效了

自从上次更新以来,我一直遇到间歇性的数据库连接错误(与我推送的udpates无关)。根据我收到的错误,应用程序正在查找错误的数据库(为localhost设置的数据库),而不是使用生产数据库。登录时失败,因为数据库不存在。我可以登录,有时客户不能,即使是在同一时间。然后我换了一台新电脑,但它坏了。我重新启动了IIS,这解决了一次,但我完全不知道发生了什么

想法:

  • dll或构建是否可能已损坏
  • IIS有什么问题吗
  • 其他想法
任何帮助,非常感谢! 斯科特J

编辑:这似乎只发生在登录时。我将登录页面改回原来的页面。它起作用了,现在它有时又停止工作了。非常令人沮丧

错误消息:

Cannot open database "companyA" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\Production'.

System.Data.SqlClient.SqlException (0x80131904): Cannot open database "companyA" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\Production'. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at PLM.Providers.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SqlConnectionHelper.cs:line 127 at PLM.Providers.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SqlConnectionHelper.cs:line 57 at PLM.Providers.SqlMembershipProvider.GetConnectionHolder() in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SQLMembershipProvider.cs:line 101 at PLM.Providers.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SQLMembershipProvider.cs:line 1704 at PLM.Providers.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SQLMembershipProvider.cs:line 1562 at PLM.Providers.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SQLMembershipProvider.cs:line 1549 at PLM.Providers.SqlMembershipProvider.ValidateUser(String username, String password) in C:\Users\Israel\Desktop\ODESK\Scott\PLMMemberhipProvider\SQLMembershipProvider.cs:line 856 at System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) at System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) at System.Web.UI.WebControls.Login.AttemptLogin() at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ClientConnectionId:5257f0df-46c9-4faa-bfea-1db4daf509b3

您正在登录什么类型的数据库?我希望您的数据存储在SQL Azure或Azure存储中


如果您的生产数据库是在worker角色中创建的,请注意,Microsoft将在您的worker操作系统需要更新时定期重新启动您的worker角色,等等。当VM重新启动时,任何本地创建的文件(包括DB文件)都将被删除。

您有多少实例在运行?也许您更新了一个实例,但没有正确更新,或者根本没有更新?@BrianReischl我只有一个VM,所有的站点都在上面运行。我希望有更好的方法在服务器上调试。我正在绞尽脑汁思考什么会导致出现间歇性问题,DNS?通常ADO.NET使用连接池,所以我不认为DNS问题会导致此问题。可能错误来自其他组件(例如,会话存储)?您希望它连接到哪种类型的数据库?SQLAzure?此外,如果您可以发布错误消息,也会有所帮助。@BrianReischl这是服务器上的SQL Server Express。我发布了错误消息。看起来您正在使用Windows身份验证,而不是传递应用程序登录名/密码。是否有可能某些线程使用无法连接到DB的其他主体运行,或者在登录过程中重置(或不重置)了DB?可能会解释为什么它适用于您而不适用于其他人。@Richard_Turner-不,它不是SQL Azure,而是服务器上的SQL Server Express实例。VM是持久的,不像web角色等,除非我遗漏了什么。