Search code examples
.netazureazure-cloud-servicesazure-management-api

How to progromatically get active instance names of a cloud service?


Hoping someone knows the specific .Net library (or if not, REST service) for getting the names of active (running instances) in a given Azure Cloud Service.

enter image description here


Solution

  • Use "RoleEnvironment.CurrentRoleInstance.Id" from the .NET code. Ensure that this code has access to ServiceRuntime DLL (usually only referenced by your WebRole or WorkerRole projects). This call will also fail in local mode, non-emulated code, so try/catch might be a good idea

    Edit: To get all instances in a role, try this? RoleEnvironment.CurrentRoleInstance.Role.Instances