我第一次尝试在azure中发布我的应用程序,但我收到了以下错误我将感谢任何关于如何修复错误的建议
建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。找不到或无法访问服务器。请验证实例名称是否正确,以及SQL Server是否已配置为允许远程连接。(提供程序:SQL网络接口,错误:26-定位指定的服务器/实例时出错)描述:在执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误以及错误在代码中的来源的更多信息。
SQLExpress数据库文件自动创建错误:
连接字符串使用应用程序的App_Data目录中的数据库位置指定本地Sql Server Express实例。提供程序尝试自动创建应用程序服务数据库,因为提供程序确定该数据库不存在。以下配置要求对于成功检查应用程序服务数据库的存在并自动创建应用程序服务数据库是必要的:
If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable automatic creation of the provider database. Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102. If the application's App_Data directory does not already exist, the web server account must have read and write access to the application's directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the application's App_Data directory already exists, the web server account only requires read and write access to the application's App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the application's App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server account's credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
来源错误:
在执行当前web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
堆栈跟踪:
[SqlException(0x80131904):建立与SQL Server的连接时,出现与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。请验证实例名称是否正确,以及SQL Server是否已配置为允许远程连接。(提供程序:SQL网络接口,错误:26-定位指定的服务器/实例时出错)]System.Data.SqlClient.SqlInternalConnectionTds.ctor(DbConnectionPoolIdentity标识、SqlConnectionString连接选项、SqlCredential凭据、对象提供者信息、字符串newPassword、SecureString newSecurePassword、布尔重定向用户实例、SqlConnectionStringuserConnectionOptions、SessionData reconnectionSessionData、DbConnectionPool池、字符串访问令牌、布尔应用程序TransientFaultHandling、SqlAuthenticationProviderManager sqlAuthProviderManager)+947System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection,DbConnectionOptions userOptions)+6043115System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions userOptions)+38System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +531 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1重试,DbConnectionOptions userOptions)+156System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 retry, DbConnectionOptions userOptions) +22 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
1重试)+92System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1重试)+219System.Data.SqlClient.SqlConnection.Open()+101System.Web.Management.SqlServices.GetSqlConnection(字符串服务器,字符串用户,字符串密码,布尔可信,字符串连接字符串)+78
[HttpException(0x80004005):无法连接到SQL Server数据库。]System.Web.Management.SqlServices.GetSqlConnection(字符串服务器,字符串用户,字符串密码,布尔可信,字符串连接字符串)+131System.Web.Management.SqlServices.SetupApplicationServices(字符串服务器,字符串用户,字符串密码,布尔可信,字符串连接字符串,字符串数据库,字符串dbFileName,SqlFeatures功能,布尔安装)+92System.Web.Management.SqlServices.Install(字符串数据库,字符串dbFileName,字符串connectionString)+30System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(字符串fullFileName,字符串dataDir,字符串connectionString)+410
错误是不言自明的。从查看堆栈跟踪。检查以下步骤:
步骤1:验证实例名称是否正确,以及SQL Server是否已配置为允许远程连接。
步骤2:提供程序试图自动创建应用程序服务数据库,因为提供程序确定
数据库不存在。
2.1如果应用程序在Windows 7或Windows Server 2008R2上运行,则需要执行特殊的配置步骤
才能自动创建提供程序数据库。
2.2App_Data目录不存在,web服务器帐户必须具有对应用程序目录的读写访问权限。
2.3web服务器帐户的进程标识必须具有本地用户配置文件。有关如何
为计算机帐户和域帐户创建本地用户配置文件的详细信息,请参阅自述文档。
您还可以检查这是否是Azure SQL PaaS在SQL Server上的防火墙设置中;允许Azure服务:应设置为";是";
您可以参考链接-https://learn.microsoft.com/en-US/troubleshoot/sql/connect/resolving-connectivity-errors