Azure Web 作业存储连接

Azure WebJob Storage Connection

我的 App.config 中有这些连接字符串用于 Azure WebJob

<add name="AzureWebJobsDashboard" connectionString="UseDevelopmentStorage=true"/>
<add name="AzureWebJobsStorage" connectionString="UseDevelopmentStorage=true"/>

因为我希望它默认为开发人员使用 Azure 存储模拟器。但是,当这些 WebJobs 在 Azure 上使用时,它们似乎仍然指向本地存储,尽管我已经在 Azure 门户界面中设置了这些连接字符串:

我推断它仍然指向本地存储,因为我收到此错误:

Microsoft.WindowsAzure.Storage.StorageException: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:10001 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

在我们的日志记录中,我们首先尝试连接到 Azure 存储。

我错过了什么吗?我是否为 WebJobs 正确设置了连接字符串?我如何将它们设置为开发人员的默认本地存储,但在 Azure 中为应用程序 运行 提供真实的连接字符串?

首先,我确定Azure 门户中的配置比web 中的配置具有更高的优先级。config/app.config.

根据您上传的图像,我看到您为 Azure 存储连接字符串选择了事件中心和 SQL 数据库类型。如果您为 Azure 存储连接字符串选择事件中心类型会出现一些问题,请将连接类型更改为自定义以解决此问题。

您可以打印出 WebJob 中的连接字符串以进行确认。

var host = new JobHost(config);

Console.WriteLine(config.DashboardConnectionString);
Console.WriteLine(config.StorageConnectionString);