【问题标题】:The element 'Startup' in namespace... has invalid child element 'environment' in namespace命名空间中的元素“启动”...在命名空间中具有无效的子元素“环境”
【发布时间】:2015-03-03 07:35:15
【问题描述】:

目标:创建环境变量,通知启动任务是在计算模拟器还是在云中运行。

错误:

错误 124 XML 规范无效:命名空间“http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition”中的元素“Startup”在命名空间“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.
)

【问题讨论】:

    标签: azure


    【解决方案1】:

    Environment 元素应该嵌套在 Task 元素中。此外,XML 元素的名称区分大小写,应为“Environment”和“Variable”。

    这里的例子: http://blog.toddysm.com/2011/03/what-environment-variables-can-you-use-in-windows-azure.html

    【讨论】:

    • 我也试过区分大小写但仍然遇到同样的问题。
    • &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ServiceDefinition name="Cloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4"&gt; &lt;WebRole name="MVC" vmsize="Small"&gt;... here is my startup script....&lt;/WebRole&gt; &lt;/ServiceDefinition&gt;
    • 知道了...here.. Environment 元素应该嵌套在 Task 元素中。谢谢...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-18
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    相关资源
    最近更新 更多