Skip to content

Repository files navigation

AzureStorageExtensions

Extensions for Azure Storage Client library

NuGet

Get it

PM> Install-Package AzureStorageExtensions

Basic usage

1. Context

Create Context is easy, just inherit from BaseCloudContext and declear property any types of CloudQueue, CloudBlobContainer, CloudTable, and new generic CloudTable<T>

publicclassMyContext:BaseCloudContext{publicMyContext(stringconnectionString):base(connectionString){}publicCloudQueueMyQueue{get;set;}publicCloudBlobContainerMyBlob{get;set;}publicCloudTable<MyClass>MyTable{get;set;}}

2. CloudTable

The new generic CloudTable allow you to create, retrieve, update, replace, merge, delete, query, and bulk opertations much easier.

varperson=awaitcontext.Person.RetrieveAsync(partitionKey,rowKey);awaitcontext.Persons.InsertAsync(newPerson);awaitcontext.Persons.InsertOrReplaceAsync(newPerson);awaitcontext.Persons.InsertOrMergeAsync(partialPerson);awaitcontext.Persons.UpdateAsync(person);awaitcontext.Persons.ReplaceAsync(person);awaitcontext.Persons.MergeAsync(partialPerson);awaitcontext.Persons.DeleteAsync(person);//bulk also support for all operationsawaitcontext.Persons.BulkInsertAsync(persons);//async query also support (required System.Linq.Async)varchildren=await(frompincontext.Persons.Query()wherep.Age<=18selectp).AsAsyncTableQuery().ToListAsync();

3. Archive Table

Table (also blob container and queue) can be parition by time. This is suitable for log or temporary data. Just add setting attribute to property in context.

publicclassMyContext:BaseCloudContext{[Setting(Period=Period.Month)]publicCloudTable<Log>Logs{get;set;}}

When new logs insert to table it will be kept based on time.
Log201410
Log201411
Log201412

4. Expandable Table Entity

Azure table limits each property to 64k, but ExpandableTableEntity allows you to keep data up to 1M limit.

publicclassLog:ExpandableTableEntity{publicstringMessage{get;set;}//this message can be up to 1M}

Migrate from 1.x

AzureStorageExtensions is no more depending on Web.Config. You can add constructor and read connection string.

publicclassMyContext:BaseCloudContext{publicMyContext():base(ConfigurationManager.ConnectionStrings[nameof(MyContext)].ConnectionString){}}

About

Extensions for Azure Storage Client library

Topics

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages