当试图连接到天蓝色的SQL时,Bot服务器返回了HTTP 5xx
问题描述:
我试图使用Azure SQL在此tutorial之后记录机器人和用户的活动。但是,bot在Azure Web应用程序仪表板中返回了HTTP 5xx错误。当试图连接到天蓝色的SQL时,Bot服务器返回了HTTP 5xx
DB在本地工作,但不是在Azure SQL上远程工作。我已将Web应用程序的所有IP添加到SQL防火墙,并将Azure SQL的connectionString复制到发布选项。当我使用Skype进行测试时,机器人没有响应,并在仪表板中显示5xx服务器错误。
<connectionStrings>
<add name="BotDataEntities" connectionString="metadata=res://*/Models.BotData.csdl|res://*/Models.BotData.ssdl|res://*/Models.BotData.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\BotData.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
是否有什么问题,我的web.config阻止bot服务器发送活动到Azure SQL?
答
检查您的编程代码,它引用LocalDB无处不在。它不针对SQL Azure数据库。
答
正如Alberto所述:您的连接字符串不正确地指向本地数据库。请尝试将其更改为类似:
<connectionStrings>
<add name="BotDataEntities" providerName="System.Data.SqlClient" connectionString="Server=[YourDatabaseServerName];Initial Catalog=[YourDatabaseName];Persist Security Info=False;User ID=[YourDatabaseUserId];Password=[YourDatabaseUserPassword];MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
注: 机器人框架队也有一个博客贴子,通过在Azure中的Sql节约活动,散步,可能对您会有所帮助:https://blog.botframework.com/2017/05/05/saving-bot-actions-on-azure-sql-server/