Posted in:

In this post I want to show how you can use the cross-platform Azurite Azure Storage emulator running as a Docker container to develop Durable Functions locally.

Background

You may know that for many years there has been an Azure Storage Emulator that can be used for local development of Azure Functions on Windows. This is great as it saves you from having to create a real Azure Storage account whenever you want to experiment with Azure Functions.

This is especially valuable if you are developing Durable Functions because they make use of a wide range of Azure Storage features including blobs, queues and table storage in order to implement task hubs.

More recently Azurite, which is cross platform, and open source has emerged as the successor to the old Windows-only storage emulator. The official documentation states:

Azurite is the future storage emulator platform. Azurite supersedes the Azure Storage Emulator. Azurite will continue to be updated to support the latest versions of Azure Storage APIs.

However, until recently Azurite has been lacking a few important features that make it suitable to fully replace the older storage emulator. In particular, Azurite did not support Table Storage until recently, making it unsuitable for use with Durable Functions.

The good news is that there is now preview support for Table storage in Azurite. You can check up in this issue to find out if it has gone GA yet. Fortunately it appears to be good enough already to support local development of Durable Functions (and apparently Logic Apps too).

Running Azurite as a Container

There are several ways you can install and run Azurite including a VS Code extension or just with a simple npm install -g azurite.

But I wanted to try it out as a container, so I started it with the following command. Note that I've included port 10002 which is the port used by table storage, which is now supported by Azurite, and necessary for Durable Functions.

docker run -d -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite

Note that in this example I'm not mounting a volume. I could do that by adding another parameter of -v c:/azurite:/data, which would allow my the contents of my emulated storage account to persist independently of the lifetime of the container. But I find that often I'm using storage emulator for a quick throwaway experiment, and so it's nice to be able to easily clean up once I'm done.

Testing it out with Durable Functions

You can try all this out very easily if you have the Azure Functions Core Tools installed.

  1. In an empty folder run func init and select dotnet as the runtime.
  2. Then run then func new and select the DurableFunctionsOrchestration template
  3. Make sure Azurite is running (you can use the docker run command shown above)
  4. Run the function app with func start
  5. Call the starter function URI to initiate a new workflow
  6. Call the statusQueryGetUri returned by the starter function to check on the workflow progress. You should see that the workflow has completed already.

Summary

If you're developing Azure Functions on a Mac or Linux, then it's definitely worth checking out Azurite. And even if you're developing on Windows and have been happy with the existing Storage Emulator, it's probably time to consider switching over to Azurite, as it is approaching feature parity, and going forwards is going to become the officially supported and recommended emulator.

Want to learn more about how easy it is to get up and running with Durable Functions? Be sure to check out my Pluralsight course Azure Durable Functions Fundamentals.

Comments

Comment by Ramesh Janjyam

Thanks for writing it up.

Ramesh Janjyam