为什么我需要在 Azure 管理门户中而不是在我的 WebJob 的 App.config 中为 WebJobs 配置连接字符串?

Why do I need to configure connection strings for WebJobs in Azure Management Portal rather than in the App.config of my WebJob?

我通过右键单击我的 WebApp 项目并添加一个新的 Azure Web 项目创建了一个预定的 Azure WebJob。我在 WebJob 项目的 App.config 中设置了 AzureWebJobsDashboard 和 AzureWebJobsStorage 连接字符串。我暂时将默认代码单独留在 .cs 文件中。接下来,我从 Visual Studio(顺便说一句,2013 更新 4)发布到 Azure 网站。它创建了 WebJob,我可以从 Azure 管理站点 运行 它或 Visual Studio 它是成功的。我可以在预期的位置看到输出日志。但是,Azure WebJob 详细信息页面显示以下 warnings/errors:

Make sure that you are setting a connection string named AzureWebJobsDashboard in your Microsoft Azure Website configuration by using the following format DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY pointing to the Microsoft Azure Storage account where the Microsoft Azure WebJobs Runtime logs are stored.

The configuration is not properly set for the Microsoft Azure WebJobs Dashboard. In your Microsoft Azure Website configuration you must set a connection string named AzureWebJobsDashboard by using the following format DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY pointing to the Microsoft Azure Storage account where the Microsoft Azure WebJobs Runtime logs are stored.

它还提供了 http://azure.microsoft.com/blog/2013/07/17/windows-azure-web-sites-how-application-strings-and-connection-strings-work/ 的 link,这并不能解释我收到错误消息的原因。

现在,要让这个 warning/error 消失,我将在 Azure 管理站点的配置页面中添加相同的 AzureWebJobsDashboard 连接字符串。

因此,我想弄清楚是我做错了什么,还是这只是 Microsoft 尚未修复的 WebJobs 中的一个问题。我真的很希望能够在 App.config 中使用它,而不必记住在我们为不同环境生成的每个网站中进行设置。

非常感谢您的宝贵时间和帮助。

仪表板无法访问您的网络作业的 app.config 文件,即使可以访问,您可能有多个网络作业,所以它不知道要选择哪个连接字符串。这就是您需要在门户中设置连接字符串的原因。

但是,如果您在门户中设置它们,则不必在 app.config 中为 Web 作业设置它。 WebJobs SDK 知道如何从那里读取它们。

我必须手动添加授权 headers:

为了在 "Basic " 之后获取值,我使用了以下代码:

var byteArray = Encoding.ASCII.GetBytes("<user>:<password>");
var base64 = Convert.ToBase64String(byteArray);

Ithink 是一个 Azure 调度程序 UI 错误