0

您好我想使用网络作业来调用以下代码:

   using (SqlConnection con = new SqlConnection(ConfigStore.RemoteConnectionString()))
   {
       using (SqlCommand cmd = new SqlCommand(xxxxxx, con))
       {
           cmd.CommandType = CommandType.StoredProcedure;

           con.Open();

           SqlDataReader reader = cmd.ExecuteReader();
           if (!reader.HasRows)
           {

           }

           while (reader.Read())
           {

           }
           reader.Close();
       }
   }

我收到以下错误

018-07-12T07:13:25 PID[4540] 信息 Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行功能时出现异常:Functions.FiveSecondTask ---> System.Data.SqlClient.SqlException:网络相关或实例- 建立与 SQL Server 的连接时发生特定错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:命名管道提供者,错误:40 - 无法打开与 SQL Server 的连接)---> System.ComponentModel.Win32Exception:访问被拒绝 2018-07-12T07:13:25 PID [4540] 内部信息结束异常 2018-07-12T07:13:25 PID [4540] System.Data.ProviderBase.DbConnectionPool.TryGetConnection 处的信息(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,1 retry,DbConnectionOptions userOptions,DbConnectionInternal& connection) 2018-07-12T07:13:25 PID[4540] Information at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 次重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接) 2018-07-12T07:13:25 PID [4540] System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection externalConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry,DbConnectionOptions userOptions) 2018-07-12T07:13:25 PID[4540] Information at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 重试,DbConnectionOptions userOptions) 2018-07-12T07:13:25 PID [4540] System.Data.SqlClient.SqlConnection.TryOpenInner 处的信息(TaskCompletionSource1 retry) 2018-07-12T07:13:25 PID[4540] Information at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 次重试)2018-07-12T07:13:25 PID[4540] System.Data.SqlClient.SqlConnection.Open() 处的信息 2018-07-12T07:13:25 PID[4540] WebJob5.Functions.FiveSecondTask 处的信息( TimerInfo timer) 2018-07-12T07:13:25 PID[4540] lambda_method(Closure ,Functions ,Object[] ) 的信息 2018-07-12T07:13:25 PID[4540] Microsoft.Azure.WebJobs.Host 的信息.Executors.VoidMethodInvoker2.InvokeAsync(TReflected instance,Object[] arguments) 2018-07-12T07:13:25 PID[4540] Information at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvokerExecuteWithLoggingAsync(??) 2018-07-12T07:13:25 PID[4540] 信息在异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:25 PID[4540 ] 信息内部异常结束 2018-07-12T07:13:26 PID [4540] 信息已执行“Functions.FiveSecondTask”(失败,Id=beb15926-66b3-4f7e-900a-ebf855feb07b)2018-07-12T07:13:26 PID[4540] 信息 Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时出现异常:Functions.FiveSecondTask ---> System.Data.SqlClient.SqlException:建立与SQL 服务器。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:1 retry,DbConnectionOptions userOptions,DbConnectionInternal& connection) 2018-07-12T07:13:26 PID[4540] Information at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 次重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接) 2018-07-12T07:13:26 PID [4540] System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry,DbConnectionOptions userOptions) 2018-07-12T07:13:26 PID[4540] Information at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 重试,DbConnectionOptions userOptions) 2018-07-12T07:13:26 PID [4540] System.Data.SqlClient.SqlConnection.TryOpenInner 处的信息(TaskCompletionSource1 retry) 2018-07-12T07:13:26 PID[4540] Information at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 次重试)2018-07-12T07:13:26 PID[4540] System.Data.SqlClient.SqlConnection.Open() 处的信息 2018-07-12T07:13:26 PID[4540] WebJob5.Functions.FiveSecondTask 处的信息( TimerInfo timer) 2018-07-12T07:13:26 PID[4540] lambda_method(Closure,Functions,Object[]) 的信息 2018-07-12T07:13:26 PID[4540] Microsoft.Azure.WebJobs.Host 的信息.Executors.VoidMethodInvoker2.InvokeAsync(TReflected instance,Object[] arguments) 2018-07-12T07:13:26 PID[4540] Information at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvokerExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540] 信息在异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540 ] 信息内部异常结束 2018-07-12T07:13:26 PID[4540] System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 处的信息 2018-07-12T07:13:26 PID[4540] 异步 Microsoft 处的信息。 Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancelToken ) 2018-07-12T07:13:26 PID[4540] 信息功能有错误。有关详细信息,请参阅 Azure WebJobs SDK 仪表板。实例 ID 为 ' beb15926-66b3-4f7e-900a-ebf855feb07b' 2018-07-12T07:13:26 PID [4540] 信息 Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时出现异常:Functions.FiveSecondTask ---> System.Data。 SqlClient.SqlException:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:命名管道提供者,错误:40 - 无法打开与 SQL Server 的连接)---> System.ComponentModel.Win32Exception:访问被拒绝 2018-07-12T07:13:26 PID [4540] 内部信息结束异常 2018-07-12T07:13:26 PID [4540] System.Data.ProviderBase.DbConnectionPool 中的信息。1 retry,DbConnectionOptions userOptions,DbConnectionInternal& connection) 2018-07-12T07:13:26 PID[4540] Information at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 次重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接) 2018-07-12T07:13:26 PID [4540] System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry,DbConnectionOptions userOptions) 2018-07-12T07:13:26 PID[4540] Information at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 重试,DbConnectionOptions userOptions) 2018-07-12T07:13:26 PID [4540] System.Data.SqlClient.SqlConnection.TryOpenInner 处的信息(TaskCompletionSource1 retry) 2018-07-12T07:13:26 PID[4540] Information at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 次重试)2018-07-12T07:13:26 PID[4540] System.Data.SqlClient.SqlConnection.Open() 处的信息 2018-07-12T07:13:26 PID[4540] WebJob5.Functions.FiveSecondTask 处的信息( TimerInfo timer) 2018-07-12T07:13:26 PID[4540] lambda_method(Closure,Functions,Object[]) 的信息 2018-07-12T07:13:26 PID[4540] Microsoft.Azure.WebJobs.Host 的信息.Executors.VoidMethodInvoker2.InvokeAsync(TReflected instance,Object[] arguments) 2018-07-12T07:13:26 PID[4540] Information at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) 2018-07-12T07:13:26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync 的信息(IFunctionInvoker 调用者, ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) 2018-07-12T07:13:26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance) 信息,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource) 2018-07-12T07:13:26 PID [4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor 的信息。ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540] 信息在异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540 ] 信息内部异常结束 2018-07-12T07:13:26 PID[4540] System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 处的信息 2018-07-12T07:13:26 PID[4540] 异步 Microsoft 处的信息。 Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancelToken )26 PID[4540] 信息内部异常结束 2018-07-12T07:13:26 PID[4540] System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 处的信息 2018-07-12T07:13:26 PID[4540] 信息在异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancelToken)26 PID[4540] 信息内部异常结束 2018-07-12T07:13:26 PID[4540] System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 处的信息 2018-07-12T07:13:26 PID[4540] 信息在异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 2018-07-12T07:13:26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancelToken)26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancelToken) 的信息26 PID[4540] 异步 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancelToken) 的信息

我如何确保 azure 可以连接到这个远程 sql 框?

我如何在不影响安全性的情况下实现这一目标?

非常感谢

4

2 回答 2

0

我找到了一个回答它的链接https://nishantrana.me/2018/02/19/using-azure-hybrid-connections-to-connect-to-sql-on-prem-database-from-azure-webjob/

于 2018-07-12T07:52:21.593 回答
0

这看起来像是一个不正确的连接字符串。您可以调试该ConfigStore.RemoteConnectionString()方法返回的内容以及它是有效的连接字符串吗?

于 2018-07-12T07:31:27.217 回答