0

I am using asp.net 4.0 and c#.net is there any way to know that by supplying applicationId or webrole name (or both) and know how many instances are present in perticular webrole?

Is there any api available so i can code with c#.net?

Amit Patel
  • 205
  • 1
  • 5
  • 15

2 Answers2

3

Yes,

foreach (var roleDefinition in RoleEnvironment.Roles) 
{ 
   foreach (var roleInstance in roleDefinition.Value.Instances) 
   { 
      Trace.WriteLine("Role instance ID: " + roleInstance.Id, "Information");
   }
}
  • it's described in more detail here. No need to complicate with the management API really.
Anže Vodovnik
  • 2,325
  • 16
  • 25
  • Note: this assumes you are running inside the same "deployment", so on Azure - if you want to check an arbitrary deployment, you need to (1) configure the management certificatae, (2) get the deployment ID, (3) use the Management API posted in Gaurav's Answer. – Anže Vodovnik Oct 17 '11 at 11:03
0

Your best bet would be to make use of Service Management REST API (http://msdn.microsoft.com/en-us/library/ee460806.aspx). Also take a look at the following thread here: SDK for Service Management API.

Community
  • 1
  • 1
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241