命名空间中的元素'Startup ...'在命名空间中具有无效的子元素'environment'
问题描述:
目标:创建环境变量,以通知启动任务它在Compute Emulator中还是在云中运行。命名空间中的元素'Startup ...'在命名空间中具有无效的子元素'environment'
错误:
错误124的XML规范无效:元素“启动”命名空间“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.
)
答
Environment元素应嵌套在Task元素中。此外,XML元素的名称区分大小写,应该是“环境”和“变量”。
这里举例: http://blog.toddysm.com/2011/03/what-environment-variables-can-you-use-in-windows-azure.html
我也试图与大小写敏感的,但仍然面临着同样的问题。 – 2015-03-05 06:18:11
明白了...... [这里] (https://msdn.microsoft.com/en-us/library/azure/hh974417.aspx).. Environment元素应该嵌套在Task元素中。谢谢... – 2015-03-05 06:22:36