I'm trying to find a way to tell if the current instance where my code is running is part of a deployment that is in a Production or Staging slot.
The problem that I'm trying to solve is this: I have a timer object that runs every few minutes and triggers certain events. When I deploy a new package to Azure, I normally deploy in the Staging slot and after some validation I do a VIP Swap to promote
that to Production.
While the instances are in the Staging slot, I want to prevent them from triggering the events.
After doing some research of the Service Management APIs, the only solution seems a bit awkward to me:
- Use Microsoft.WindowsAzure.ServiceRuntime to determine the Deployment Id for the current instance
- Add an entry to the Service Configuration to include the Subscription Id
- Add the Azure Management Certificate to the Hosted Service
- Use the Service Management RESTful APIs to query for all the hosted services and their production deployments
- Look for the Deployment Id from Step 1 with the list of Production Deployment Ids in Step 4.
This should work, but I would prefer to avoid steps 2 and 3. Given that this instance is already running on Azure, it is clearly associated with a subscription that the code has been deployed by somebody who was authenticated with the management certificate.
Since this package is going to be deployed in multiple hosted services and subscriptions, I'd prefer to minimize the deployment of management certificates and the configuration overhead.
So, is this the only approach or are there any others that would simplify the deployment?
Thanks!