This project is read-only.

Working withs Blobs

Resource Model

  • Blobs are web resources (e.g. files) stored on one or more cloud provider datacenters. They follow REST principles (e.g. GET/PUT, ETag, LastModified).
  • They can be read or written.
  • They are grouped into named Containers
  • They have a unique path inside their container. Paths can be a hierarchy of folders
  • Blobs have Metadata (name/value collection pairs), which can be read/written independently of their content.


- At minimum you must define your provider connection string. See ConnectionStrings
    <add name="Azure" providerName="System.StorageModel.WindowsAzure.AzureProvider, Cloud4Net.Azure" connectionString="YourAzureConnectionString"/>
    <add name="AWS" providerName="System.StorageModel.AWS.AWSProvider, Cloud4Net.AWS" connectionString="YourAWSConnectionString"/>

- You can also define static blob containers. These containers will be automatically created on startup if they do not already exist.
Warning: container names and blob paths have restrictions of their associated provider (most of the time a container name must comply with a DNS subdomain rules for CDN exposure).
    <sectionGroup name="system.storageModel">
      <section name="blobs" type="System.StorageModel.Configuration.BlobStorageSection, Cloud4Net.Abstractions" />
    <!-- specify the default provider for blobs -->
    <blobs defaultProvider="Azure">
      <!-- containers registered hereunder will be created on startup if they not already exist -->
      <container name="pictures"/>
      <container name="videos"/>

      <!-- you can assign a different provider to each container (provider attribute) -->
      <container name="cdn-images" provider="AWS"/>

Code Model

  • You can code against the generic model using IBlobProvider, IBlobContainer and IBlobSpec interfaces:
  • You can also code against the provider-specific model (AzureProvider, AWSBlobContainer, etc.) to get provider-specific features:
var provider = Storage.GetProvider<AzureProvider>("Azure");
var container = provider.Containers["test-container"];
container.MetaData["data1"] = "value1";
container.UpdateMetaData(); // container metadata feature is specific to Azure Blob Storage


How-to Azure AWS NTFS Cache
Get a specific provider from configuration Supported Supported Supported Supported
Create a blob container Supported Supported Supported Supported
Delete a blob container Supported Supported Supported Supported
Does a blob container exists ? Supported Supported Supported Supported

Get a specific blob provider from config

using System.StorageModel;
var provider = Storage.GetProvider<IBlobProvider>("Name");

Create a blob container

// create the specified container (throws an exception if it already exist)
// create the specified container (without throwing an exception)

Delete a blob container

// delete the specified container (throws an exception if it does not exist)
// delete the specified container (without throwing an exception)

Does a blob container exist ?

// test if the specified container exist
var exist = provider.Containers["container-name"].Exist;
implementation note: for performance purpose, the Exist property is evaluated once per container object (e.g. if you test it multiple times on the same object, the provider will not check again). To check multiple time if a container exist, get another reference to the container (by calling providers.Containers["container-name"] again)

Last edited May 9, 2010 at 10:43 AM by JazBee, version 13


No comments yet.