CloudNimble.Breakdance.Azurite package handles all the complexity of
starting, configuring, and stopping Azurite instances during your test runs.
Prerequisites
Before you begin, ensure you have:1
Node.js installed
Azurite runs on Node.js. Install it from nodejs.org or via your package manager.
2
Azurite installed globally
Install Azurite globally using npm:
3
NuGet package installed
Add the Breakdance Azurite package to your test project:
Quick Start
The simplest way to get started is to create a test class that inherits fromAzuriteTestBase:
MyStorageTests.cs
Configuration Options
TheAzuriteConfiguration class provides extensive options for customizing your Azurite instance:
Selecting Services
You can start only the services you need to reduce resource usage and startup time:- All Services
- Blob Only
- Queue Only
- Multiple Services
Storage Persistence
By default, Azurite runs with in-memory persistence, which is fast and automatically cleans up after tests:Port Configuration
Breakdance automatically assigns random ports (20000-30000) to avoid conflicts when running tests in parallel:All Configuration Options
Accessing Azurite
Once your test class is set up,AzuriteTestBase provides convenient properties for connecting to the services:
Endpoint properties return
null if that service was not requested in the configuration.
For example, if you set Services = AzuriteServiceType.Blob, then QueueEndpoint and TableEndpoint will be null.Testing Patterns
Testing Blob Storage
Testing Queue Storage
Testing Table Storage
Advanced Scenarios
Sharing an Instance Across Multiple Test Classes
If you have many test classes that need the same Azurite configuration, you can use assembly-level initialization:AssemblySetup.cs
Using with Dependency Injection
If your application uses dependency injection, you can register Azure Storage clients with the Azurite connection string:Troubleshooting
Azurite fails to start
Azurite fails to start
Ensure Node.js and Azurite are installed:If Azurite is not found, install it globally:
npm install -g azuritePort conflicts
Port conflicts
By default, Breakdance uses random ports and retries on conflicts. If you’re seeing persistent
port issues, check for orphaned Azurite processes:
Tests interfere with each other
Tests interfere with each other
Each test class should have its own static
AzuriteInstance field. If you’re sharing an instance,
use unique resource names in each test to avoid conflicts.Slow startup times
Slow startup times
- Use
InMemoryPersistence = truefor faster startup - Only start the services you need (e.g.,
AzuriteServiceType.Blobinstead ofAll) - Consider sharing an instance across test classes if appropriate
Related Resources
Azurite Documentation
Official Microsoft documentation for Azurite
Azure Storage SDKs
.NET SDK documentation for Azure Storage