Jan Blaha

Blog about software development

Azure Blob Storage file system abstraction for on premise

.NET Azure architecture

Whole project is stored on github

Our current project is SaaS with the requirement to run also on premise. We need to store reports for thousands of tenants therefore we are using Azure Blob Storage. That works fine for Azure cloud based SaaS application. However we cannot use Azure Blob Storage on premise because our clients run on their servers without internet connection and do not want to store data in the cloud. Therefore I have created file system abstraction that can run against Windows Azure Storage as well as local hard drive.

Idea is very simple. Use one file system interface in whole your application and just choose the right implementation (Azure Blob Storage or File System) on startup. The file system interface and proper implementations can be downloaded from nuget.

PM> Install-Package BlobFileSystem.Azure

This is how you create particular implementation of the file system interface:

//storage using azure blob client
IStorageProvider azureStorage = new AzureBlobStorageProvider(CloudStorageAccount.DevelopmentStorageAccount);

//storage using fileSystem
IStorageProvider fileSystemStorage = new FileSystemStorageProvider();

Then you can call IStorageProvider interface methods and create folders in the same way for the file system or azure storage. Checkout github for detail description.

The best it to put the correct imlementation to the dependency injection container and then you don't need to care about anything.

IStorageProvider storage;

if (ConfigurationManager.AppSettings["useFileSystem"] == "true")
    storage = new FileSystemStorageProvider();
else 
    storage = new AzureBlobStorageProvider(CloudStorageAccount.Parse(""));

Container.RegisterInstance(storage).As<IStorageProvider>().SingleInstance();

last blog posts


09-12-2017 18:40 jsreport

Quite some time ago I blogged about rendering pdf reports in c#. Recently we have added excel reports into jsreport and it was released with a little delay also into .NET. This means you should be able to use both html-to-xlsx and xlsx recipes to create excel files from your .NET environments now.

read more

09-10-2015 14:09 AWS

Such a very common thing like adding an existing external volume to Amazon elastic beanstalk is not easily supported out of the box. The official blog mentions only how to attach a snapshot or how to attach and overwrite a new volume every time the service starts. It took me a while to make the config file actually adding an existing volume without formatting it every time so I share it here with you...

read more

04-10-2015 14:09 jsreport

The best practice when adding email notifications feature to your system is to separate as much as you can from email body assembling to email sending outside of the core system. The emails templates quite likely often changes and you don't want to deploy the system because of every single notification change. The best is to just separate everything into an external system and give the access to your PR or Marketing department so they change emails as the time goes without affecting the core system.

read more

Jan Blaha

About author

Hi! My name is Jan Blaha. I'm software developer and startup enthusiastic. See my current work.