Azurite: Azure Services on Your Machine

Azurite Docker Container Configuration and Sample Code

Adem Catamak
3 min readJan 20, 2024

Yazının Türkçe versiyonuna bu link aracılığıyla ulaşabilirsiniz.

We use different tools and platforms in the software development process. We install tools in the environment where we develop, sometimes to store data and sometimes to meet our caching needs. Thanks to Docker, we can complete the installation processes in a very short time and without any problems.

In this article, we will see how we can create the Microsoft Azure Blob Storage service, one of the most frequently used tools when we encounter file operations, on our own computer using Docker.

Note: Using this method, you can also run Queue Storage and Table Storage services on your local computer. You can access the sample project and docker-compose file via this GitHub link.

Photo by Ruchindra Gunasekara on Unsplash

What is Azurite?

Azurite is an open source emulator. With this emulator, you have the opportunity to use storage units such as Blob Storage, Table Storage and Queue Storage in your local environment.

How to Set Up Azurite?

You can access different installation methods of Azurite through this link. I used the method of installing the application by downloading the image from DockerHub.

To avoid providing port information repeatedly during the docker run process, you can adjust the docker-compose file as follows.

# Username: devstoreaccount1 
# Password: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==

version: "3.4"


container_name: default-azurite
- 10000
- 10001
- 10002
- "10000:10000"
- "10001:10001"
- "10002:10002"
- default-azurite-volume:/data


How Can I Access My Storage Media with the Interface?

Using this link, you can download the Microsoft Azure Storage Explorer application according to the operating system you use. You can view and manage storage spaces through this application.

Bonus: File Upload Process with Sample Code Snippet

Considering that I will use different values in different environments such as dev, stage, prod; I placed the information I will use to access the storage area in appsettings.json as follows.

"AzureBlobServiceConfig": {
"BaseUrl": "http://localhost:10000/devstoreaccount1/",
"AccountName": "devstoreaccount1",
"Password": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

I added Azure.Storage.Files.DataLake and Microsoft.Extensions.Azure nuget packages to my project.

I used the following code snippet in the application startup section where I manage dependencies. In this way, I managed Azure Blob Service connection settings in a single place.

AzureBlobServiceConfig azureBlobServiceConfig = configuration.GetSection("AzureBlobServiceConfig").Get<AzureBlobServiceConfig>();
services.AddAzureClients(builder => { builder.AddBlobServiceClient(azureBlobServiceConfig.BaseUrl, new StorageSharedKeyCredential(azureBlobServiceConfig.AccountName, azureBlobServiceConfig.Password)); });

// Custom Class
services.AddScoped<IBinaryStorageService, AzureBlobService>();

In the AzureBlobService’s constructor method, I created the container in which I will store the data.

public AzureBlobService(BlobServiceClient blobServiceClient)
_blobContainerClient = blobServiceClient.GetBlobContainerClient(ContainerName);

From this point on, I can place the information I want into the container. Below, I put the code snippet that is in the notebook sample project. This piece of code stores the text given to a given file path.

public async Task<Uri> PutContentAsync(string path, string content, CancellationToken cancellationToken)
BlobClient blobClient = _blobContainerClient.GetBlobClient(path);

await using Stream stream = await blobClient.OpenWriteAsync(true, cancellationToken: cancellationToken);
await using var writer = new StreamWriter(stream);
await writer.WriteAsync(content);
await writer.FlushAsync();

return blobClient.Uri;

We took a brief look at what Azurite is and how it can be easily installed in a local environment. I hope it was a useful article. You can click on this link to check out my other articles.