If you work with Azure Storage events, you are in the right place. This article is not about the different classes of storage , but how to emulate them locally with Azurite. We will be emulating Azure storage locally to test events (functions ) triggered by Azure storage types .
Azurite currently supports Blob, Queue and Table storage emulation. If you are new to Azure Storage, it will be helpful to give a read to this article.
First things first
Before proceeding further, we need some tools ready in your laptop. Have the following installed:
Assuming you have setup, your environment let’s get cracking.
Steps
- Download the Azurite Docker image
docker pull mcr.microsoft.com/azure-storage/azurite
After this when you run the following command you should be able to see the docker image.
sudo docker image ls
2. Run the Docker image
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
mcr.microsoft.com/azure-storage/azurite
Now observe the output carefully . You will see that each service Blob , Queue , Table is associated with a dedicated port.
If you are looking to run a specific type of storage you can try this command
docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite \
azurite-blob --blobHost 0.0.0.0 --blobPort 10000
Just the change the highlighted parts to the relevant storage type such as queue or table and proceed.
3. Configure the Storage Emulator
Your Azure Storage Emulator application has a startup page like this. Click on the “plug” icon to get the connect manager
Click on Local Storage Emulator
Just the name the connection as “Azurite” and leave everything default ( unless you made a change when you started the docker container ) and hit next .
Now you should your Azurite Storage Emulator visible
Now you have successfully configured your local storage emulator. Let’s test this quickly.
To test this I’m going to create a simple Queue trigger with Azure Functions.
Before doing that, I’m going to create a queue called “test-local-queue” in my storage emulator window.
Simply , right click the Queues and “Create a queue”. Remember to use the same name or at the least any name without underscores. Azure Storage naming conventions are to blame.
Before proceeding further, you might see some interesting logs getting generated by the docker image that we started. They are simply logs for actions that we did in the storage emulator.