0
votes

Goal: Create the environment variable that informs the startup task whether it is running in the Compute Emulator or in the cloud.

Error:

Error 124 The XML specification is not valid: The element 'Startup' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' has invalid child element 'environment' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'. List of possible elements expected: 'Task' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'. D:\PrasadP_Workspace\FlexPathCapital\flexpathazurecloudmigration\flexpathazurecloudmigration\FlexPath.Cloud\ServiceDefinition.csdef 11 8 FlexPath.Cloud

StartUp task:

 <Startup>
  <Task commandLine="startup.cmd" executionContext="elevated" taskType="simple" />
  <environment>

     <!--create the environment variable that informs the startup task whether it is running 
           in the compute emulator or in the cloud. "%computeemulatorrunning%"=="true" when 
           running in the compute emulator, "%computeemulatorrunning%"=="false" when running 
           in the cloud.--> 

    <variable name="computeemulatorrunning">
      <roleinstancevalue xpath="/roleenvironment/deployment/@emulated" />
    </variable>

  </environment>
</Startup>

enter image description herestartup.cmd:

After it i will check the environment in cmd file to perform my task.

    REM   Check if this task is running on the compute emulator
IF "%ComputeEmulatorRunning%" == "true" (
    REM   This task is running on the compute emulator. Perform tasks that must be run only in the compute emulator.
) ELSE (
    REM   This task is running on the cloud. Perform tasks that must be run only in the cloud.
)
1

1 Answers

1
votes

The Environment element should be nested inside the Task element. Also, the names of the XML elements are case sensitive, and should be "Environment" and "Variable".

Example here: http://blog.toddysm.com/2011/03/what-environment-variables-can-you-use-in-windows-azure.html