I have configured the Azure AppFabric Cache as session provider in my ASP.NET MVC application.
How do i store session data in Azure Cache?
Is it the same was as with inProc session?
Like by using ViewBag, TempData and stuff?
Thanks.
If you haven't already, I'd encourage you to have a look at this section in the Windows Azure Training Kit. It does a very good job of demonstrating how to use Windows Azure Caching.
http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_buildingappswithcacheservice#_Toc310505077
If you configured AppFabric as session provider you can now use Session State just in the same way when you had InProc session. Other features that use Session State (for example TempData) also work.
Related
How can I manage the session in Oracle JET application.
I've been working on small pilot application where I need to check if the user is logged in on every request.
I didn't find any resource on the same as the framework is recently published by Oracle.
JET uses web sessions if you configure it as a web application. So authentication would be managed by the Web server.
Frank
Because of the client nature of JS source, there's no session on the JET side of your application, Session is a (HTTP) browser feature. You might handle session exactly the way you did with a pure JavaScript, JQuery, Angular or everything else application.
There may be two ways to do it
Use web server to manage the sessions.
You can store session values (some data after login REST API call) in local storage or sessions storage based on your need. For managing
session you can check in your app controller and redirect based on
that.
Hope this help, please let me know if you faced any problem. I have recently implemented session in Oracle JET based on the above points.
I'm currently building a site that will be hosted in Microsoft Azure. The last site I created in this hosting environment used "Windows Azure Shared Caching". Some of you may already be aware that "Windows Azure Shared Caching" service will soon be deprecated over the next year.
I have applied for the preview release of "Windows Azure Cache". However, I'm finding that my request is still "queued".
I wouldn't mind using "Windows Azure Shared Caching" since the site I'm building will only be live for around 10 weeks and the fact it being deprecated next year doesn't worry me. However, I am unable to create a new caching service through the old Azure Management Portal since new caching has to be done using "Windows Azure Cache".
So my question...
Since my application for the new caching platform is still yet to be approved and I am unable to create a new caching service under the old platform, what other options are there? Have I missed something?
Microsoft is surely making things difficult.
The other option you have is using In-Role Cache for Web/Worker roles (Azure Cloud Services). Any role within the same cloud deployment can access the cache. If you have just 1 web role - this acts very similar to ASP.NET State Server which provides an in-memory cache. However, as you add more web roles - you can choose to distribute this in-memory cache across all roles or use a dedicate worker role for managing the cache.
Dedicated In-Role Cache: worker role uses all available memory
Co-Located In-Role Cache: percentage of available memory is used across all roles
See In-Role Cache FAQ on MSDN for more details.
Your request should have been approved (irrespective of whether yours is a paid/trial/free subscription). If it still hasn't, put the query up here. This is the forum for Cache.
This is a proper release of the Cache Service! The core is very mature and Microsoft is giving great support on top of it. Go ahead and use it!
This flavor of Cache is THE right one for Azure Websites.
Leave a post at the forum for any concerns/issues you have. It is being constantly monitored and replied to.
I guess I am the first to suggest Azure Redis Caching?
I am hosting an on-premises website which I want to migrate to Windows Azure Virtual machine.I will be using multiple instances of Azure VMs. Currently I am using IN-Proc session management technique. Do I really need to change this session mode to migrate the website to cloud. Why??
If you want to have more than 1 Web Role Instance (for load balancing/scalability/redundancy purposes) then Yes you do need to change it. Just a reminder, but you need a minimum of 2 roles in order to be eligible for the 99.9% SLA.
InProc means that the session information is stored in that web roles process. a second web role instance, has no knowledge of that data contained in process in the first web role.
So if your first web request goes to WEBROLE_1 it has your session information.
If your second request goes to WEBROLE_2, it won't know that you already have some session data stored in the other role.
There are a number of other options for storing your session info including using TableStorage, SQL Azure or App Fabric Cache.
The Problem
I'm creating an application that runs on Glassfish 3.1.2.2 and exposes a RESTful API in an environment where authentication is expensive. Passing the credentials and authenticating every request isn't feasible - I need a session-based approach.
I'm looking at using BASIC auth and in-memory session replication (the app needs to support deployment in a cluster). In-memory replication seems expensive considering I'm only sharing "logged in" state - every other component of the applicaiton is stateless.
My question is: Is there a better alternative?
e.g. Can I configure Glassfish to persist session state to a database, instead of using in-memory replication?
I've considered a "session as a resource" approach e.g. POST to /session to login, DELETE /session/{id} to logout. This provides more control, however it's more difficult for the service consumers (vs something like BASIC auth).
Can anyone tell me that if I use Session(inside an ASP.NET MVC 3 application) in Windows Azure environment with multiple instances(means multiple virtual machines), then it work without any configuration or I need to use ASP.NET Universal Providers or I need to handle this manually by using AppFabric?
You can't use in-process session state, but must use a shared session state provider.
The only supported session state model is to use Azure Cache, but you can use a provider that works with either Azure Storage or SQL Azure.
UPDATE:
I wrote some articles on my blog which go into using SQL Azure for session state with Entity Framework Code First. Hopefully, you'll find useful pointers there, even if you're not using Entity Framework.
Something to bear in mind using the standard SQL Server Session State Provider is that it doesn't have the retry logic which is considered good practice when working with SQL Azure.
This discussion on ASP.NET MVC providers may help you:
http://azureproviders.codeplex.com/discussions/276053
, also, look here for how to implement a session provider using Azure AppFabric Caching:
http://weblogs.asp.net/shijuvarghese/archive/2011/05/04/using-windows-azure-appfabric-caching.aspx
"...Without any configuration..."
As Steve Morgan mentioned, The Azure AppFabric Cache provides a supported mechanism for caching. The cache itself is independent from your compute instances. In fact, a single cache could be accessed by multiple applications, if you wanted to use it in such a way.
Regarding configuration, you'll have to modify web.config, as the AppFabric Cache has a custom cache provider. The web.config snippet itself is auto-generated for you via the portal; it's as easy as copy-n-paste.
You can find out more info on caching, including sizes and pricing, here.