Export (0) Print
Expand All

xPath Values in Windows Azure

Updated: November 13, 2013

Starting with Windows 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 Windows Azure.

xpath="/RoleEnvironment/Deployment/@emulated"

Using the @emulated location path for the deployment is functionally equivalent to the follow statement:

var x = RoleEnvironment.IsEmulated;

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:

var deploymentId = RoleEnvironment.DeploymentId;

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:

var id = RoleEnvironment.CurrentRoleInstance.Id;

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:

var ud = RoleEnvironment.CurrentRoleInstance.UpdateDomain;

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:

var fd = RoleEnvironment.CurrentRoleInstance.FaultDomain;

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:

var rname = RoleEnvironment.CurrentRoleInstance.Role.Name;

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:

var setting = RoleEnvironment.GetConfigurationSettingValue("Setting1");

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:

var localResourcePath = RoleEnvironment.GetLocalResource("LocalStore1").RootPath;

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:

var localResourceSizeInMB = RoleEnvironment.GetLocalResource("LocalStore1").MaximumSizeInMegabytes;

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:

var prot = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].Protocol;

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:

var port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint.Port;

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:

var address = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint.Address;

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>

See Also

Show:
© 2014 Microsoft