|  | Sign in
Expand
1 out of 1 rated this helpful Rate this topic

Overview of Startup Tasks for Roles in Windows Azure

Updated: April 13, 2011

You can use startup tasks to perform operations before the role starts. Operations that you might want to perform include installing a component, registering COM components, setting registry keys, or starting a long running process. You add startup tasks to the role by defining the Startup element for the tasks in the ServiceDefinition.csdef file.

noteNote
Startup tasks are not applicable to VM roles.

Add the startup task to the service model definition

A startup task for a role must define the permission level for the task and the manner in which the task runs. The following attributes define a startup task:

  • executionContext – the attribute that defines the permission level. This value can be limited or elevated. The limited level of permissions are the same level as those of the role. The elevated level of permissions are those of the Administrator account. For example, you may need to set a registry key. To do this, use the elevated execution context.

  • taskType – the attribute that defines the manner in which the task runs. The following types of running processes are available:

    • Simple (Default) – running of the role instance is blocked until the task finishes.

    • Background – the role continues to run while the task runs.

    • Foreground – similar to Background, but the role cannot be stopped until the task finishes.

      noteNote
      Foreground tasks block the recycling of role instances, so you should be careful when developing them to avoid service interruption.

Define environment variables before a role instance starts

You can define environment variables for a role by adding the Runtime element to the definition of the role in the service definition file.

Getting started with defining startup tasks for a role

To get started developing a server image for a VM role that you can upload to Windows Azure, see Getting Started with Defining Startup Tasks for Roles in Windows Azure

See Also

Did you find this helpful?
(1500 characters remaining)