1 out of 1 rated this helpful - Rate this topic

Define Environment Variables Before a Role Starts

Updated: April 13, 2011

You can define environment variables for a role by adding the Runtime element to the definition of the role in the service definition file. For more information about these elements, see the Service Definition Schema.

You can edit the ServiceDefinition.csdef file by using your favorite text editor.

  1. Open the ServiceDefinition.csdef file for your service in the text editor.

  2. Add the Runtime element to the WebRole, WorkerRole, or VirtualMachineRole element. The following code example shows how to set an environment variable for the web role:

    
    <ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
       <WebRole name="WebRole1">
          <Runtime>
             <Environment>
                <Variable name="MyEnvironmentVariable" value="MyVariableValue" />
             </Environment>
          </Runtime>     
       </WebRole>
    </ServiceDefinition>
    
  3. Change the name value to the name of the variable, and change value to the value of your variable.

  4. Save the file.

See Also

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter