简体   繁体   English

我需要一个Azure存储帐户来运行WebJob吗?

[英]Do I need an Azure Storage Account to run a WebJob?

So I'm fairly new to working with Azure and there are some things I can't quite wrap my head around. 因此,我刚接触Azure时还有些陌生,有些事情我还无法完全解决。 One of them being the Azure Storage Account. 其中之一是Azure存储帐户。

My web jobs keeps stopping with the following error "Unhandled Exception: System.InvalidOperationException: The account credentials for ' [account_name] ' are incorrect." 我的Web作业不断停止,并出现以下错误“未处理的异常:System.InvalidOperationException:' [account_name] '的帐户凭据不正确。” Understanding the error however is not the problem, at least that's what I think. 但是,理解错误不是问题,至少我是这样认为的。 The problem lies in understanding why I need an Azure Storage Account to overcome it. 问题在于了解为什么我需要一个Azure存储帐户来克服它。

Please read on as I try to take you through the steps taken thus far. 请继续阅读,我将逐步引导您完成目前所采取的步骤。 Hopefuly the real question will become more clear to you. 希望真正的问题对您更加清楚。

In my efforts to deploy a WebJob on Azure we have created the following resources so far: 到目前为止,在我努力在Azure上部署WebJob的过程中,我们已经创建了以下资源:

  • App Service Plan 应用服务计划
  • App Service 应用服务
  • SQL server SQL服务器
  • SQL database SQL数据库

I'm using the following code snippet to prevent my web job from exiting: 我正在使用以下代码段来防止我的Web作业退出:

JobHostConfiguration config = new JobHostConfiguration();
config.DashboardConnectionString = null;
new JobHost(config).RunAndBlock();

To my understanding from other sources the Dashboard connection string is optional but the AzureWebJobsStorage connection string is required. 据我从其他来源了解,仪表板连接字符串是可选的,但AzureWebJobsStorage连接字符串是必需的。

I tried setting the required connection string in portal using the configuration found here . 我尝试使用此处找到的配置在门户中设置所需的连接字符串。

DefaultEndpointsProtocol=[http|https];AccountName=myAccountName;AccountKey=myAccountKey

Looking further I found this answer that clearly states where I would get the values needed, namely an/my missing Azure Storage Account. 往前看 ,我发现此答案清楚地说明了在哪里可以获得所需的值,即缺少我的Azure存储帐户。

So now for the actualy question: Why do I need an Azure Storage Account when I seemingly have all the resources I need place for the WebJob to run? 所以现在要问一个实际的问题:当我似乎拥有运行WebJob所需的所有资源时,为什么需要一个Azure存储帐户? What does it do? 它有什么作用? Is it a billing thing, cause I thought we had that defined in the App Service Plan. 这是一笔帐单吗,因为我认为我们已经在应用程序服务计划中定义了这一点。 I've tried reading up on Azure Storage Accounts over here but I need a bit more help understanding how it relates to everything. 我已经尝试在这里阅读Azure存储帐户,但是我需要更多帮助来了解它与所有内容之间的关系。

From the docs: 从文档:

An Azure storage account provides resources for storing queue and blob data in the cloud. Azure存储帐户提供用于在云中存储队列和Blob数据的资源。

It's also used by the WebJobs SDK to store logging data for the dashboard. WebJobs SDK也使用它来存储仪表板的日志记录数据。

Refer to the getting started guide and documentation for further information 有关更多信息,请参阅入门指南和文档。

The answer to your question is "No", it is not mandatory to use Azure Storage when you are trying to setup and run a Azure web job. 问题的答案为“否”,在尝试设置和运行Azure Web作业时,并非必须使用Azure存储。

If you are using JobHost or JobHostConfiguration then there is indeed a dependency for Storage accounts. 如果使用的是JobHostJobHostConfiguration则存储帐户确实存在依赖性。

Sample code snippet is give below. 下面是示例代码段。

class Program
{
    static void Main()
    {
        Functions.ExecuteTask();
    }

}

public class Functions
{
    [NoAutomaticTrigger]
    public static void ExecuteTask()
    {
        // Execute your task here 
    }
}

The answer is no, you don't. 答案是否定的,你不是。 You can have a WebJob run without being tied to an Azure Storage Account. 您可以运行WebJob,而不必绑定到Azure存储帐户。 Like Murray mentioned, your WebJob dashboard does use a storage account to log data but that's completely independent. 就像Murray提到的那样,您的WebJob仪表板确实使用存储帐户来记录数据,但这是完全独立的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM