Using Azure Storage Outside of Azure Hosting

Azure provides a set of storage services – blob, queue, and table – that are accessed via REST interfaces. The Azure SDK provides a sample .Net library that wraps the REST API to make Azure Storage easy to consume.


As long as you have Internet connectivity, these services are available to your application anywhere. I have a hosting account at GoDaddy and wanted to check the feasibility of storing data in Azure while hosting outside of the Azure data center.


To accomplish this, I simply copied the Lib folder from the Azure Storage Client sample in the Azure SDK. This contains all of the helper functions that make accessing Azure storage from .Net simple. To help me keep things clear, I renamed the project and the folder StorageLibNoDepend.


Next I created a console solution in Visual Studio and added the StorageLibNoDepend project to the solution. A quick compile verified that everything works.


Now to break it …

I removed the reference to Microsoft.ServiceHosting.ServiceRuntime from the StorageLib project and let the compiler find the dependencies. The first dependency was a using statement in StorageAccountInfo.cs (it turns out that all of the changes are in this one file). All of the other changes had to do with reading configuration settings from the Azure config service rather than the config files. I simply deleted these large blocks of code (5 or 6 of them) and the system compiled.


Next I added an app.config file with the following settings:



    <add key="AccountName" value="youraccountname"/>

    <add key="AccountSharedKey" value="yourkey"/>

    <add key="BlobStorageEndpoint" value=""/>

    <add key="QueueStorageEndpoint" value=""/>

    <add key="TableStorageEndpoint" value=""/>

    <add key="UsePathStyleUris" value="false"/>



You will need to update the AccountName and AccountSharedKey values appropriately.


Next, add a reference to the StorageLibNoDepend project to the console application. Also add the following using statement to the console app.

using Microsoft.Samples.ServiceHosting.StorageClient;


Paste the following code into the Main method of the console application.

BlobStorage blobStorage = BlobStorage.Create(StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration());

foreach (BlobContainer b in blobStorage.ListBlobContainers())







When you press F5, the application should run and display a list of all of the blob containers in your account.


With this library, you can use Azure storage from any application, not just an app running in the Azure hosted environment. So far, the performance has been quite good as has the availability of Azure Storage. I currently have three different applications – a web app hosted at GoDaddy, a web app hosted in Azure, and a console app – accessing the same database tables – no replication, synchronization, or conflict management to deal with!


Obviously, there are some performance implications to this model, but so far, the performance has been very good. The key is limiting the amount of data returned whenever possible.

The possibilities enabled by this type of cloud database are very exciting and the Azure Storage Library makes it very simple to consume.