SPRZEDAŻ: 1-800-867-1389
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

Define Startup Tasks for a Role

Updated: November 13, 2013

You can define a startup task for a role by adding the Startup element to the definition of the role in the service definition file. For more information about these elements, see the Windows Azure Service Definition Schema (.csdef File).

You can edit the ServiceDefinition.csdef file by using your favorite text editor, or you can define the tasks for the role by using Visual Studio.

To edit the definition file

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

  2. Add the Startup element to the WebRole or WorkerRole; startup tasks are not applicable to the VMRole. The following code example shows how to add a startup task to a web role that runs a command script:

    <ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
       <WebRole name="WebRole1">
             <Task commandLine="Startup.cmd" executionContext="limited" taskType="simple">
    The commandLine task is relative to the AppRoot\Bin folder for the deployment. Environment variables are not expanded in the commandLine value. If environment expansion is required, you can create a small .cmd script that calls your startup task as cmd.exe, which expands the environment variables.

  3. Set the commandLine value to the name of the program or script file that you want to run.

  4. Set the executionContext to the level of permissions that you want for your startup task.

  5. Set the taskType to simple, foreground, or background depending on how you want the task to run. For more information on taskType, see WorkerRole Schema.

  6. Save the file.

See Also

Czy oceniasz te materiały jako pomocne?
(Pozostało znaków: 1500)
Dziękujemy za opinię.
© 2014 Microsoft