4

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.

Manic Lama
  • 65
  • 1
  • 7

3 Answers3

2

From the docs:

An Azure storage account provides resources for storing queue and blob data in the cloud.

It's also used by the WebJobs SDK to store logging data for the dashboard.

Refer to the getting started guide and documentation for further information

Murray Foxcroft
  • 12,785
  • 7
  • 58
  • 86
  • 1
    The docs you linked still mention making an Azure storage account. If it's true that I don't have to create one it doesn't help me understand how to achieve this. – Manic Lama Jul 13 '17 at 07:15
  • You don't need one, no. Is it good practice to monitor your log files, yes. So it is not mandatory, but it is recommended. – Murray Foxcroft Jul 13 '17 at 08:51
  • Here Im not using any dashboard logging or any logging connected to Azure storage. When I was using v1.x of this webjobs sdk, even storage string is mandatory, nothing was written into the azure storage. But when I used v.2.x of this sdk, it creates a blob container called azure-webjobs-hosts and write some data. Why azure is having this info in this blob? – XPD Sep 22 '18 at 16:55
  • Seems like webjobs is taking a dependency on storage. I know durable functions now relies on storage to maintain state. I haven't had chance to look at what functions 2.x is storing in the blob. – Murray Foxcroft Sep 23 '18 at 20:11
2

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 
    }
}
Viswas Menon
  • 310
  • 3
  • 11
0

The answer is no, you don't. You can have a WebJob run without being tied to an Azure Storage Account. Like Murray mentioned, your WebJob dashboard does use a storage account to log data but that's completely independent.

lopezbertoni
  • 3,551
  • 3
  • 37
  • 53
  • I'm assuming I would have to remove the code snippet I posted from my code to have it not log data. My next problem would be how to keep my program from exiting cause that's what I'm using JobHost(config).RunAndBlock(); for? – Manic Lama Jul 13 '17 at 07:47
  • You don't need the JobHost either. A WebJob can be a simple console application. The JobHost is part of the WebJobs SDK which you are not required to use. – lopezbertoni Jul 13 '17 at 14:38