Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can Azure maintain APPLICATION state?

Tags:

state

azure

I know how Azure preserves SESSION state -- I've implemented it in my app using AppFabric based on Neil MacKenzie's Microsoft Windows Azure Development Cookbook. However, that approach based on AppFabric apparently does not preserve APPLICATION state (e.g. Application["name"] = MyObject ), which my app needs.

I suspect I will need to use Azure Tables, but that will require recoding. So before going down that path, I'd like to know if there is a simpler approach to preserve application state, preferably one that does not require recoding of my app.

Thanks,

Bill

like image 381
Hoyacoder Avatar asked Feb 21 '23 08:02

Hoyacoder


2 Answers

Sorry, there's nothing like a direct replacement for the Application[key] approach.

Your best bet would be to use Azure caching. You're already using Azure caching indirectly I believe, using the approach from the book above for Session state.

The downside perhaps is that cached items don't stay around forever, their max life is about 72 hours. So anytime you access a cached item, you'll have to test similar to the psuedo code below:

object o = cache.Get("MyItem"); 
if (o != null){ 
   MyType myType = (MyType) o; 
   //use the item
} 
else 
{  
//recreate the item 
}
like image 86
ChrisW Avatar answered Feb 28 '23 09:02

ChrisW


It's worth noting, that Microsoft recommends SQL database as the preferred storage way for server-side state management.

Although I would stick to Azure caching as mentioned by Chris.

like image 23
Baccata Avatar answered Feb 28 '23 10:02

Baccata