c# - Determine Azure Web Role's instance IP address -


the ip address looking not vip, nor private ip address given role instance, public ip address can assign each instance using configuration:

  <networkconfiguration>     <addressassignments>       <instanceaddress rolename="webrole1">         <publicips>           <publicip name="public" />         </publicips>       </instanceaddress>     </addressassignments>   </networkconfiguration> 

using powershell cmdlets, 1 able find ip address given each instance this:

ps c:\> get-azureservice -servicename "rr-testservice" | get-azurerole -instancedetails 

which output results, this:

instanceerrorcode            : instancefaultdomain          : 0 instancename                 : webrole1_in_0 instancesize                 : small instancestatedetails         : instancestatus               : readyrole instanceupgradedomain        : 0 rolename                     : webrole1 deploymentid                 : 69a82ec9bb094c31a1b79021c0f3bbf2 ipaddress                    : 100.79.164.151 publicipaddress              : 137.135.135.186 publicipname                 : public publicipidletimeoutinminutes : publicipdomainnamelabel      : publicipfqdns                : {} servicename                  : rr-testservice operationdescription         : get-azurerole operationid                  : 00400634-f65d-095b-947f-411e69b9a053 operationstatus              : succeeded 

where in case ip addresses 137.135.135.186 , 137.135.133.191 ones looking retrieve in .net / c# (in role instance itself)

any advice on appreciated.

thanks!

you make use of azure management libraries wrapper on azure service management api powershell cmdlets.

i wrote simple console application made use of these libraries fetch ip address of instances of cloud service:

    static void getcloudservicedetails()     {         var subscriptionid = "<your azure subscription id>";         var managementcertdatafrompublishsettingsfile = "<management cert data publish settings file>";         var cert = new x509certificate2(convert.frombase64string(managementcertdatafrompublishsettingsfile));         var credentials = new certificatecloudcredentials(subscriptionid, cert);         var computemanagementclient = new computemanagementclient(credentials);         var cloudservicename = "<your cloud service name>";         var cloudservicedetails = computemanagementclient.hostedservices.getdetailed(cloudservicename);         var deployments = cloudservicedetails.deployments;         foreach (var deployment in deployments)         {             console.writeline("deployment slot: " + deployment.deploymentslot);             console.writeline("-----------------------------------------------");             foreach(var instance in deployment.roleinstances)             {                 console.writeline("instance name: " + instance.instancename + "; ip address: " + string.join(", ", instance.publicips.select(c => c.address.tostring())));             }         }     } 

you use code cloud service.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -