10

I want to be able to test an Azure WebJobs SDK project locally, before I actually publish it to Azure.

If I make a brand new Azure Web Jobs Project, I get some code that looks like this:

Program.cs:

// To learn more about Microsoft Azure WebJobs SDK, please see http://go.microsoft.com/fwlink/?LinkID=320976
class Program
{
    // Please set the following connection strings in app.config for this WebJob to run:
    // AzureWebJobsDashboard and AzureWebJobsStorage
    static void Main()
    {
        var host = new JobHost();
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }
}

Functions.cs:

public class Functions
{
    // This function will get triggered/executed when a new message is written 
    // on an Azure Queue called queue.
    public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
    {
        log.WriteLine(message);
    }
}

I would like to get around to testing whether or not the QueueTrigger function is working properly, but I can't even get that far, because on host.RunAndBlock(); I get the following exception:

An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll

Additional information: Microsoft Azure WebJobs SDK Dashboard connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways:

  1. Set the connection string named 'AzureWebJobsDashboard' in the connectionStrings section of the .config file in the following format , or

  2. Set the environment variable named 'AzureWebJobsDashboard', or

  3. Set corresponding property of JobHostConfiguration.

I ran the storage emulator, and set the Azure AzureWebJobsDashboard connection string like so:

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

but, when I did that, I'm getting a different error

An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll

Additional information: Failed to validate Microsoft Azure WebJobs SDK Dashboard account. The Microsoft Azure Storage Emulator is not supported, please use a Microsoft Azure Storage account hosted in Microsoft Azure.


Is there any way to test my use of the WebJobs SDK locally?

2 Answers2

7

WebJobs 2.0 now works using development storage (I'm using v2.0.0-beta2).

Note that latency in general and Blob triggers in particular are currently far better than you can get in production. Design with care.

chadwackerman
  • 804
  • 12
  • 9
5

If you want to test the WebJobs SDK locally, you need to set up a storage account in Azure. You can't test it against the Azure Emulator. That's what that error is telling you.

Failed to validate Microsoft Azure WebJobs SDK Dashboard account. The Microsoft Azure Storage Emulator is not supported, please use a Microsoft Azure Storage account hosted in Microsoft Azure.

So to answer your question, you can create a storage account in Azure using the portal, and then set up your connection string in the app.config of your Console Application. Then just drop a message to the queue and run the Console Application locally and it will pick it up (assuming you're trying to interact with the queue obviously).

Make sure that you replace the [QueueTrigger("queue")] "queue" with the name of the queue you want to poll.

Hope this helps

lopezbertoni
  • 3,551
  • 3
  • 37
  • 53
  • So there's no way to test this offline? – Sam I am says Reinstate Monica Dec 15 '15 at 18:49
  • No, you need to test against a real storage account, can't use the emulator. It's really easy to set up though. – lopezbertoni Dec 15 '15 at 18:51
  • 3
    We have a tracking item for local emulator support, but it's not supported currently. See the tracking item here: https://github.com/Azure/azure-webjobs-sdk/issues/53. Note that the AzureWebJobsDashboard connection string isn't required (only if you want to view your logs in the Dashboard). The AzureWebJobsStorage connection string IS required. – mathewc Dec 15 '15 at 19:35
  • 1
    You may be able to test this locally now. That github issue is closed and as of Emulator 4.3 (4.4 is latest), it has improved support for queues. – Dan Csharpster May 30 '16 at 21:00
  • Nope... unless you go out of your way to install some random nuget / unknown package of some kind... basically this doesn't come out of the box "as per design" – Scott Apr 05 '17 at 01:35