How to get environment variable and information in startup task
-
2010年12月24日 2:33
I am trying the new startup task feature from azure 1.3
But I don't know how to get the enviroment variables in the startup task, such as role approot, and local resource path. As I want to do some processing in startup task.
<WebRole name="WebRole1">
<Startup>
<Task commandLine="Startup.cmd" executionContext="limited" taskType="simple">
</Task>
</Startup>
</WebRole>
すべての返信
-
2011年1月20日 4:50
Hi,
If I understood it correctly..you want to set and access environment variable from cmd / code file.You can define the environment variable in CSDEF file http://msdn.microsoft.com/en-us/library/gg432991.aspx and you should be able to access it in your code using something like this System.Environment.GetEnvironmentVariable .
In .cmd/batch file you should be able to access it using "%VARIABLE%" (Variable is the name of environment variable here)
Hope this helps.
-Sachin Sancheti
-Life was much simpler when apple and blackberries were just fruits. -
2011年3月24日 19:13モデレータ
Maybe late but still - you can use %ROLEROOT% which points to your Role's root folder. Your role's approot folder is %ROLEROOT%\Approot.
Hope this helps.
This posting is provided "AS IS" with no warranties, and confers no rights.
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
2011年5月5日 11:23
to add to this
can I have parameters for my start up tasks ?
eg I have to unzip a file lying somewhere on c drive but it can be any xyz file .. so can i specify name as argu to my start up task !
S Arora -
2011年5月5日 14:34
No, but your startup task can just be a batch file that calls something else with a parameter. So if you want to call "foo.exe xyz" just make a batch file called foo.cmd with "foo.exe xyz" in it, and then call foo.cmd as a startup task.- 回答の候補に設定 Arora S 2011年5月12日 12:13
-
2011年5月6日 4:17
Thanks Steve
however how do I make that parameter reach till that nested foo.exe through my startup task.
PS : your blog and cloud cover videos are simply great Steve.
S Arora -
2011年5月12日 12:13
I am now calling my process from worker role with Process.start and passing argument with process start info
S Arora- 回答の候補に設定 Arora S 2011年5月12日 12:13
-
2011年8月10日 8:41
Hello Steve, but i think there is another problem, in staging i can see more units, c: d: e: and in my code i must to autodetect in witch of those units is installed IIS, then i configure my ISAPI for perl in the Web.config and i must to put the full path (and i don´t know witch the correct path). How can i ask in the method onstart where is installed IIS or which is the correct unit or the full path incluyin unit? in producction i see less unit only see c: and d: and i don´t know why.
Thank you for you help
-
2011年8月10日 18:19I'm not sure how your question relates to this thread. Perhaps you should start a new thread and clarify what you're trying to do?
-
2011年8月11日 7:40Ups, sorry, ok i will open a new thread.
-
2012年9月17日 12:59
Hi..
I want to add Environment variable in my csdef file. When I <Environment> element in my ServiceDefinition.csdef file, it's giving me error.
Warning 1 The element 'VirtualMachineRole' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' has invalid child element 'Startup' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'. List of possible elements expected: 'Certificates, LocalResources, Endpoints, ConfigurationSettings' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'. c:\users\administrator\documents\visual studio 2010\Projects\WindowsAzure6_Env\WindowsAzure6_Env\ServiceDefinition.csdef 7 6 WindowsAzure6_Env
My File look like below
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzure6_Env" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
<VirtualMachineRole name="VMRole1" vmsize="Small">
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
<Startup>
<Environment>
<Variable name="MY_ENV" value="my_value" />
</Environment>
</Startup>
<Runtime>
<Environment>
<Variable name="MY_SECOND_ENV" value="my_value2" />
</Environment>
</Runtime>
</VirtualMachineRole>
</ServiceDefinition>
Please let me know if you have any solution.Thanks

