目标:创建环境变量,通知启动任务它是在Compute Emulator中运行还是在云中运行。
错误:
错误124 XML规范无效:元素' Startup'在命名空间' http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'有无效的子元素'环境'在命名空间' http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'。预期可能元素列表:'任务'在命名空间' http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'。 D:\ PrasadP_Workspace \ FlexPathCapital \ flexpathazurecloudmigration \ flexpathazurecloudmigration \ FlexPath.Cloud \ ServiceDefinition.csdef 11 8 FlexPath.Cloud
启动任务:
<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>
的 STARTUP.CMD:
之后,我将检查cmd文件中的环境以执行我的任务。
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.
)
答案 0 :(得分:1)
Environment元素应嵌套在Task元素中。此外,XML元素的名称区分大小写,应该是&#34; Environment&#34;和&#34;变量&#34;。
此处示例: http://blog.toddysm.com/2011/03/what-environment-variables-can-you-use-in-windows-azure.html