博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Skipping Windows Azure Startup Tasks When Running in the Emulator
阅读量:6605 次
发布时间:2019-06-24

本文共 1851 字,大约阅读时间需要 6 分钟。

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

Startup tasks are often used in Windows Azure to install things or make other configuration changes to the virtual machine hosting your role code. Sometimes those setup steps are things you don’t want to execute when you’re running and testing locally via the compute emulator. (For example, you may want to skip a lengthy download or an installation of something you already have on your computer.)

With SDK 1.5, there are a few supported ways for code to determine whether or not it’s running emulated. From .NET code, there’s the new static property. From other code (like a batch file startup task), SDK 1.5 adds a nice way to put the value of IsEmulated into an environment variable. Here’s the definition of a startup task that will get an EMULATED environment variable telling it whether or not the role is running under the compute emulator.

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

Note the xpath attribute. There are many useful paths you can provide that will help you get at things like the port for an endpoint, the location of a local storage resource, or configuration setting values. See the MSDN documentation for the full details: and .

Now all we need to do is make use of this environment variable in our startup task. The first line of startup.cmd simply checks the environment variable and immediately exit if it’s set to true:

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

I used to write all sorts of tests in my startup tasks to try to avoid rerunning installers on my laptop, and this nice feature is going to save me the effort.

转载地址:http://sefso.baihongyu.com/

你可能感兴趣的文章
xcode - 移动手势
查看>>
细说浏览器特性检测(1)-jQuery1.4添加部分
查看>>
古中国数学家的计算力真是惊人
查看>>
Java基础-算术运算符(Arithmetic Operators)
查看>>
XML 基础
查看>>
C#编程(四十七)----------集合接口和类型
查看>>
【转】关于大型网站技术演进的思考(十二)--网站静态化处理—缓存(4)
查看>>
积跬步,聚小流------Bootstrap学习记录(1)
查看>>
HDUPhysical Examination(贪心)
查看>>
HTML5 FileAPI
查看>>
使用tdcss.js轻松制作自己的style guide
查看>>
SecureCRTPortable.exe 如何上传文件
查看>>
C++中public、protected及private用法
查看>>
苹果公司的产品已用完后门与微软垄断,要检查起来,打架!
查看>>
顶级的JavaScript框架、库、工具及其使用
查看>>
AYUI -AYUI风格的 超美 百度网盘8.0
查看>>
简明 Python 教程
查看>>
Photoshop操作指南
查看>>
用MPMoviePlayerController做在线音乐播放
查看>>
嵌入式开发之字符叠加---gb2313 国标码,utf8 国际码,unicode 无码
查看>>