I'm developing a WCF sercvice in Azure, in a web-role. I build an index in memmory, and use it to serve wcf request. My problem is that this index is gone from the memory after iis is recycling. Is there any way, to detect the recycling event, and copy the index to the memory again?
Thansk for your help.
Yes you can detect it in the Application_End event (in your Global.asax.cs).
The better solution would be not to put the index in memory. Since you're using a Web Role, you can use Windows Azure Caching (you won't need to pay extra for this). By using Windows Azure Caching you can store the index in memory, but not in the process of the application pool. It's still super-fast and it can survive application pool recycles.
Another advantage is that, when you store the index in Windows Azure Caching, all instances and roles in the same deployment will be able to use the same cache. This means they'll all use the same index you store in it.