Azure Web应用程序连接到SQL数据库随机错误
我有一个需要连接到Azure SQL数据库的Azure Web应用程序。 我的测试方法是使用托管身份来验证Web应用程序。
因此,在我的Web应用程序中,我激活了托管身份,之后我登录了数据库并运行以下脚本:
CREATE USER [<identity-name>] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [<identity-name>];
ALTER ROLE db_datawriter ADD MEMBER [<identity-name>];
保存并更新了数据库的连接字符串到我的Web应用程序中并重新启动。 一切都完美地工作了几个小时,之后我开始遇到此错误:
Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user '<token-identified principal>'.
at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
这很让我感到困惑,因为在WB应用程序的重新启动后,我可以看到Web应用程序能够连接到数据库并检索数据。 。
这是以前发生的任何人吗?可以将我带到正确解决此问题的正确道路上?
不用说,我更新了我的EntityFramework和Data.sqlclient,以促进该方法如有记录。
非常感谢您提供的任何帮助
I have an azure web application running that need to connect to an Azure SQL Database.
My testing approach is to authenticate the web app by using Managed identity.
So in my web app I activated the managed identity, after that I logged into my database and run the following script:
CREATE USER [<identity-name>] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [<identity-name>];
ALTER ROLE db_datawriter ADD MEMBER [<identity-name>];
Saved and updated the connection string of my database into my web app and restarted.
Everything worked perfectly for a couple of hours, after that I start getting this error:
Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user '<token-identified principal>'.
at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
This is kind f confusing me because after the restart of the wb app, I can see that the web app is able to connect to the database and retrieve data..but suddenly after a couple of hours it starts throwing that error.
Did this occurred to anybody before and can direct me on the right path to solve this issue?
Goes without saying that I updated my Entityframework and Data.SqlClient to the correct version to facilitate this approach as documented.
Thank you so much for any help you can provide
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论