How to read Windows Azure Application Endpont IP Address and Port values in the Startup Task

 In the following example I have a startup task Startup.cmd  which launch another batch file showconfvalues.cmd which will show the IP address and Port Value.



cd /d "%~dp0"

Start /w showconfvalues.cmd



@echo on

@echo Your IP Address is: %ADDRESS%

@echo Your PORT is: %PORT%


In the Service Definition below you can see I am using the Port value as 8999:




<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureCmdApp" xmlns="">
<WorkerRole name="CmdWorkerRole" vmsize="ExtraSmall">
<Variable name="ADDRESS">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='HttpIn']/@address" />
<Variable name="PORT">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='HttpIn']/@port" />
<ProgramEntryPoint commandLine="Startup.cmd" setReadyOnProcessStart="true" />
<InputEndpoint name="HttpIn" protocol="tcp" port="8999" />



<?xml version="1.0"?>
<ServiceConfiguration xmlns:xsi="" xmlns:xsd="" serviceName="AzureCmdApp" xmlns="">
<Role name="CmdWorkerRole">
<ConfigurationSettings />
<Instances count="1" />


You can launch this application from Windows Azure SDK Command prompt in the Administrator mode as below:


When running this application you will see the results showing your IP address and Port as below:

IP Address:

Port: 8999


Project Files:

  • build.cmd
  • pack.cmd
  • run.cmd
  • ServiceConfiguration.cscfg
  • ServiceDefinition.csdef
  • CmdWorkerRole <FOLDER>
    • Startup.cmd 
    • showconfvalues.cmd


Study more about xPath Values in Windows Azure


Get this project from github as below:

Comments (0)

Skip to main content