是否可以在ServiceDefinition.csdef xml文件中使用环境变量?
我正在努力实现这个目标:
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-03.2.0">
<WorkerRole name="MyService" vmsize="Small">
<Startup>
<Task commandLine="Create.cmd config_%DeploymentId%" executionContext="elevated" taskType="simple" >
<Environment>
<Variable name="DeploymentId">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='DeploymentId']/@value" />
</Variable>
</Environment>
</Task>
...
create.cmd批处理以字符串形式接收参数,不会被实际的部署ID值替换。
有可能实现这个目标吗?
答案 0 :(得分:0)
为什么需要在命令行上传入%DeploymentId%?您可以让Create.cmd中的代码引用%DeploymentId%环境变量。
答案 1 :(得分:0)
本文可能会有所帮助,包含有关在CSDEF中设置环境变量的教程:http://blog.toddysm.com/2011/03/what-environment-variables-can-you-use-in-windows-azure.html