4

I have a few settings in my applications that rely on the deployment slot. I understand the penalties and implications such a design decision incurs, but the decision is final and works for our case.

What I would like to know is what events fire when you change a hosted service's Deployment Slot (if any)? The RoleEnvironmentTopologyChange looked correct, but in the decsription it says it fires when the number of instances changes, so that's not what I'm looking for.

The reason I need it is to invalidate the cache that is holding the slot - that is further passed on to the resolver that gets the data specific to the deployment slot.

Anže Vodovnik
  • 2,325
  • 16
  • 25

2 Answers2

2

There's no event that fires during a VIP swap. If you want to change something when you swap, I would recommend making a config setting and changing that before you do the swap.

user94559
  • 59,196
  • 6
  • 103
  • 103
  • Damn. Looks like I need a follow-up question: http://stackoverflow.com/questions/7110092/fetching-azure-subscription-id-deployment-slot-really-fast :) – Anže Vodovnik Aug 18 '11 at 15:37
  • 1
    @smarx Probably you mean "after" instead of "before". If configuration is changed before, old value could be cached again. – Matej Aug 18 '11 at 15:42
  • 1
    No, I meant before. You don't want to move your app to production while it's still in "staging" mode (whatever that means for your app). So you usually want to change the config setting and *then* move the app into production. – user94559 Aug 18 '11 at 21:27
0

You can detect a VIP swap by inspecting the host header for each request passed to your WCF or web server from the gateway. You can also detect your current slot by checking if the host is a GUID.

See below on how to persist variables between calls How to write a WCF service with in-memory persistent storage?

var host = WebOperationContext.Current.IncomingRequest.Headers["Host"] ?? "";

if (host != currentHost)
{
    
    // do something

    currentHost = host;
}
alamoot
  • 1,966
  • 7
  • 30
  • 50
Joe Perkins
  • 160
  • 2
  • 6