Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

posted on 2012-04-11 18:45  Lei Zhang的博客  阅读(1387)  评论(1编辑  收藏  举报