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

Viewed 6043

So I'm fairly new to working with Azure and there are some things I can't quite wrap my head around. One of them being the Azure Storage Account.

My web jobs keeps stopping with the following error "Unhandled Exception: System.InvalidOperationException: The account credentials for '[account_name]' are incorrect." 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.

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:

  • App Service Plan
  • App Service
  • SQL server
  • SQL database

I'm using the following code snippet to prevent my web job from exiting:

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.

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.

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? 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.

3 Answers

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.

If you are using JobHost or JobHostConfiguration then there is indeed a dependency for Storage accounts.

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 
    }
}
Related