《Windows Azure Platform 系列文章目录》

 

  前一章里我们已经介绍了如何使用Windows Azure Startup来执行额外的配置任务,比如注册COM组件和注册Windows Service。

  另外,在Windows Azure SDK 1.5的时候,有新的API可以确定当前是否是在模拟器下运行。在.NET里有新的RoleEnvironment.IsEmulated静态属性。

  但是如果你在本地调试模拟器时,想在测试的时候不想执行Startup的步骤。我们改怎么办?

  我们看下面这个Startup节点:

<Startup>
  <Task executionContext="elevated" commandLine="startup\startup.cmd">
    <Environment>
      <Variable name="EMULATED">
        <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
      </Variable>
    </Environment>
  </Task>
</Startup>

  注意xpath 属性。你可以提供很多种有用的path,将帮助你获得如端点的端口、本地存储资源的位置或配置的setting值。详细信息请查看MSDN文档:“xPath Values in Windows Azure” 和“WebRole Schema”。

  好,接下来是重点:如果我们在模拟器环境时,不想执行Startup的步骤,那么我们就修改(commandLine的内容)startup文件夹下的startup.cmd文件。

  在startup.cmd的第一行输入以下内容

if "%EMULATED%"=="true" goto :EOF

  上面的代码意思是:如果侦测到是在模拟器状态,也就是ture,就立刻退出。

 

  参考内容:http://blog.smarx.com/posts/skipping-windows-azure-startup-tasks-when-running-in-the-emulator

相关文章:

  • 2021-09-12
  • 2022-01-11
  • 2021-10-15
  • 2022-01-14
  • 2022-01-29
  • 2021-09-09
  • 2021-07-03
  • 2022-03-09
猜你喜欢
  • 2021-07-27
  • 2021-09-15
  • 2021-08-06
  • 2021-09-16
  • 2021-08-14
  • 2021-07-24
  • 2022-02-09
相关资源
相似解决方案