xPath Values in Azure
Starting with Azure SDK 1.5 you can use the xPath element in a web role or a worker role service definition file to retrieve runtime configuration values. The following table represents the supported xPath values and their functional equivalent in the Service Runtime API.
xPath Purpose | Description |
---|---|
Determine whether the deployment is running on in the compute emulator or on Azure. |
xpath="/RoleEnvironment/Deployment/@emulated" Using the @emulated location path for the deployment is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the deployment ID for the instance. |
xpath="/RoleEnvironment/Deployment/@id" Using the @id location path for the deployment is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the current role ID for the instance. |
xpath="/RoleEnvironment/CurrentInstance/@id" Using the @id location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the update domain of the instance. |
xpath="/RoleEnvironment/CurrentInstance/@updateDomain" Using the @updateDomain location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the fault domain of the instance. |
xpath="/RoleEnvironment/CurrentInstance/@faultDomain" Using the @faultDomain location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the role name of the instances. |
xpath="/RoleEnvironment/CurrentInstance/@roleName" Using the @roleName location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the value of the specified configuration setting. |
xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='Setting1']/@value" Using the @value location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the local storage path for the instance. |
xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='LocalStore1']/@path" Using the @path location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the size of the local storage for the instance. |
xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='LocalStore1']/@sizeInMB" Using the @sizeInMB location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the endpoint protocol for the instance. |
xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='Endpoint1']/@protocol" Using the @protocol location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the endpoint port for the instance. |
xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='Endpoint1']/@port" Using the @port location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
Retrieves the endpoint IP address for the instance. |
xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='Endpoint1']/@address" Using the @address location path for the current instance is functionally equivalent to the follow statement:
For more information, see the RoleEnvironment Class. |
The following service definition segment shows the usage of the xPath element:
<WorkerRole name="Role1">
<ConfigurationSettings>
<Setting name="Setting1" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="LocalStore1" sizeInMB="1024"/>
</LocalResources>
<Endpoints>
<InternalEndpoint name="Endpoint1" protocol="tcp" />
</Endpoints>
<Startup>
<Task commandLine="example.cmd inputParm">
<Environment>
<Variable name="TestConstant" value="Constant"/>
<Variable name="TestEmptyValue" value=""/>
<Variable name="TestIsEmulated">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated"/>
</Variable>
…
</Environment>
</Task>
</Startup>
<Runtime>
<Environment>
<Variable name="TestConstant" value="Constant"/>
<Variable name="TestEmptyValue" value=""/>
<Variable name="TestIsEmulated">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated"/>
</Variable>
…
</Environment>
</Runtime>
...
</WorkerRole>