Optionally provide private feedback to help us improve this article...

Thank you for your feedback!


Using Windows Azure Blob Storage Within InstantForum

NOTE: The information within this article applies to InstantForum 2016 and above. Windows Azure Blob storage support is not available in earlier versions of InstantForum.

This article describes how to configure InstantForum to store images embedded within posts, profile photos & profile banners uploaded by users within a central Windows Azure Storage container.

Storing user uploads within Windows Azure can be helpful if you wish to centralize file storage for load balanced scenarios or if you wish to separate the serving of static files from your application server. In addition files stored within Windows Azure Storage are automatically replicated for redundancy and you can optionally leverage the Azure Content Delivery Network (CDN) for local file delivery.

Creating Your Windows Azure Storage Account

To take advantage of the Windows Azure blob storage support offered by InstantForum you'll first need to create a Windows Azure Storage account via the Windows Azure Management Portal. You can find detailed instructions on how to create new storage accounts here,

Once you've created your storage account via the Windows Azure Portal you will need to obtain the Account Name and Access Key for your storage account. You will need to click your new storage account within the Windows Azure Management Portal and select the "Manage Access Keys" option as shown below...

You will need to make a note of your Account Name and Access Key within the Manage Access Key dialog for the storage account you wish to use. You will need to add both the Account Name and Access Key into the Windows Azure Storage Account connection string which can be found within the InstantForum web.config file within the InstantASP.Common/Providers secgtion.

This connection string is shown below...

<fileSystem defaultProvider="AzureBlobStorageProvider">
<providers>
<add name="LocalStorageProvider" type="InstantASP.InstantForum.Providers.FileSystem.LocalStorageProvider, InstantASP.InstantForum" />
<add name="AzureBlobStorageProvider" type="InstantASP.InstantForum.Providers.FileSystem.AzureBlobStorageProvider, InstantASP.InstantForum" connString="DefaultEndpointsProtocol=https;AccountName=your-account-name;AccountKey=your-access-key" containerName="instantforumu" />
</providers>
</fileSystem>

You will need to add your Account Name and Access Key into the "connString" attribute within the AzureBlobStorageProvider registration.

You can optionally rename the storage container that will be created within your storage account via the "containerName" attribute. This storage container will be automatically created for you if one does not already exist within your Windows Azure Storage account.

NOTE: I'ts important to remember Windows Azure storage container names must always be lowercase and should not contain special characters. If your container name is not valid an exception will be throw by InstantForum when you first attempt to upload a file to Azure blob storage.

Enable Windows Azure Blob Storage within InstantForum

InstantForum implements a provider model design pattern for file storage. This allows developers to easily swap out or extend the implementation of files storage within InstantForum. For example you could choose to store files on Amazon S3 or other cloud storage providers. We'll be offering additional out-the-box providers within future releases of InstantForum based on customer feedback.

By default InstantForum is configured to store files locally on the web servers hard drive within the "Uploads" folder found within the root of your InstantForum installation. This is managed by the "LocalStorageProvider" which is the default file system provider used by InstantForum.

To take advantage of Windows Azure Blob Storage you will need to change the default file system provider used by InstantForum. You can do this quite easily via the web.config file like so...

1. Open your InstantForum web.config within NotePad or Visual Studio
2. Locate the InstantASP.Common/Providers section as shown below...

 <InstantASP.Common>
<!-- providers allow developers to swap or extend functionality -->
<providers> ... removed for readability ... </providers> </InstantASP.Common>

You will see a File System provider section as shown below. You can see within the "defaultProvider" attribute that the "LocalStorageProvider" is specified as the default provider as highlighted below...

<fileSystem defaultProvider="LocalStorageProvider">
<providers>
<add name="LocalStorageProvider" type="InstantASP.InstantForum.Providers.FileSystem.LocalStorageProvider, InstantASP.InstantForum" />
<add name="AzureBlobStorageProvider" type="InstantASP.InstantForum.Providers.FileSystem.AzureBlobStorageProvider, InstantASP.InstantForum" connString="DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=access-key" containerName="instantforumu" />
</providers>
</fileSystem>

To take advantage of Windows Azure Blob Storage you will need to change the "defaultProvider" to use the "AzureBlobStorageProvider" offered within InstantForum 2016 and above like so...

<fileSystem defaultProvider="AzureBlobStorageProvider">
<providers>
<add name="LocalStorageProvider" type="InstantASP.InstantForum.Providers.FileSystem.LocalStorageProvider, InstantASP.InstantForum" />
<add name="AzureBlobStorageProvider" type="InstantASP.InstantForum.Providers.FileSystem.AzureBlobStorageProvider, InstantASP.InstantForum" connString="DefaultEndpointsProtocol=https;AccountName=your-account-name;AccountKey=your-access-key" containerName="instantforumu" />
</providers>
</fileSystem>

Testing Files Are Being Uploaded To Windows Azure Blob Storage

The easiest way to test if everything is working correctly is to simply post a message within InstantForum and embed an image within the post. This image will be uploaded to your Windows Azure Storage Account within the container you specified.

If everything is successful after you upload the image you should notice the image URL points to the end point URL for your storage account as shown below...

If you view your storage container within the Windows Azure Management Portal you'll also see the files you upload via InstantForum...

That's It!

We hope this article helped you configure Windows Azure Blob Storage within InstantForum. This is a new feature so we'll likely improve this documentation over time. If we can assist with anything not covered here please don't hesitate to open a support ticket or contact us.