Search code examples
c#.netazureazure-web-rolesazure-worker-roles

How do I detect the current subscription id from inside Azure role?


Azure Management API calls require a subscription id as a parameter. Now suppose an Azure role wants to scale itself up so it wants to pass "current subscription" id as that parameter. How does it find it?

So far I've seen many implementations of that but the subscription id is always arbitrarily setup - either hardcoded or passed as a parameter but each time it comes from a user, the role never obtains subscription id on itself.

Is there a way for an Azure role to find the current subscription id from the environment?


Solution

  • There's no way to get this information from within the role itself. Your best shot is to pass it as a configuration value and retrieve it using RoleEnvironment.