Fetching Azure Subscription ID & Deployment Slot (really fast)
As a follow up to my question about Deployment Status, I'd like to ask if there is a fast way to find:
- Current Subscription Id
- The current deployment slot the role is in (Staging/Production)
I am currently using the Management API, which is a bit slow, but I don't want to cache it for long because I can't be sure the cache will invalidat开发者_Python百科e upon the slot swap.
From a running instance, you might be able to tell if you are in staging/production from the host URL for a web role. If you see your deployment ID there, it is staging. However, this can get tricky if you are using CNAMEs or you are running a worker role. For subscription ID, there is not much you can do as that is a pre-cursor to everything. You can't even use the Mgmt API if you don't know your SubID (there is no way that I am aware of to get the subscription ID other than portal).
Seems like the management API is your best bet (and only bet in some cases).
精彩评论