【问题标题】:Accessing on-premises SQL database with web application hosted on Azure使用 Azure 上托管的 Web 应用程序访问本地 SQL 数据库
【发布时间】:2012-07-18 17:01:09
【问题描述】:

我正在尝试从 Azure 中托管的服务访问公司场所中存在的 SQL 数据库。 这是我尝试过的:

  1. 在本地服务器上创建 MS SQL 数据库
  2. 创建了示例 Web 应用程序(Windows Azure 云服务)
  3. 修改 web.config 文件以获得正确的 SQL 连接字符串
  4. 使用 Azure 管理门户中的激活令牌激活 Web 角色
  5. 在本地服务器上安装本地端点
  6. 将 Web 应用程序发布到 Azure
  7. 使用 Web 角色和本地端点创建端点组
  8. 启动应用程序
  9. 试图从数据库中获取记录。

尝试使用 Azure 从数据库中获取记录时出现以下错误:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at WebRole1._Default.btnGetEmployee_Click(Object sender, EventArgs e)

请帮忙。

【问题讨论】:

  • 它是否适用于 Compute Emulator 而不是 Azure?你测试过你的连接字符串吗?
  • 你能告诉我们你的连接字符串吗(去掉密码/用户等敏感信息)。确保您的本地 SQL Server 配置了组合身份验证,并且您拥有用于连接的 SQL Server 用户。
  • 它在计算模拟器上运行良好。
  • @astaykov 下面是使用的连接字符串: 我可以使用 SQL Server Management Studio 使用连接字符串中传递的用户名/密码访问数据库。
  • 安装 SQL 的服务器上的本地防火墙怎么样,它允许从外部连接到端口 1433?还有 SQL Server 监听 IPv6?

标签: .net windows azure connect


【解决方案1】:

Trusted_Connection 必须为假。您不能从 Azure 进行 Windows 身份验证。

【讨论】:

猜你喜欢
  • 2015-06-07
  • 1970-01-01
  • 2023-03-29
  • 2021-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-22
  • 1970-01-01
相关资源
最近更新 更多