Skip to content
kendaleiv.com
Go back

Starting, Stopping, and Clearing the Azure Storage Emulator in C#

If you’re writing code that uses Microsoft Azure Storage blobs, tables, or queues, you can use the storage emulator on Windows for local development — rather than relying on the cloud while developing. And, using the RimDev.Automation.StorageEmulator NuGet package, you can interact with it in C#!

First, install the RimDev.Automation.StorageEmulator NuGet package.

PM> Install-Package RimDev.Automation.StorageEmulator

Now, it’s as simple as:

var automation = new AzureStorageEmulatorAutomation();

automation.Start();

AzureStorageEmulatorAutomation.IsEmulatorRunning(); // should be true

automation.ClearAll();

// Or, clear only certain things:
automation.ClearBlobs();
automation.ClearTables();
automation.ClearQueues();

automation.Stop();

AzureStorageEmulatorAutomation.IsEmulatorRunning(); // should be false

AzureStorageEmulatorAutomation implements IDisposable, too, but it only stops the emulator on dispose if that specific automation instance is what started it:

using (var automation = new AzureStorageEmulatorAutomation())
{
    automation.Start();

    // Work with the running Azure Storage Emulator here.
}

// Outside the scope of the using, if the Azure Storage Emulator was
// started by `automation.Start();` above, then it should be shut down.
// If it was already running, it should remain running.

Closing note

The GitHub repository associated with the RimDev.Automation.StorageEmulator NuGet package is https://github.com/ritterim/automation-storage-emulator.


Hi, I'm Ken

Jesus follower, husband, father, software engineer.

I share things I've learned, problems I've worked through, and notes worth keeping — mostly about software, sometimes about other things.

Browse my posts, explore my speaking engagements, or learn more about me.


Previous Post
Displaying DateTime in Browser Time Zone in ASP.NET Razor Views
Next Post
Once Per Test Run: Using the Azure Storage Emulator with xUnit.net v2