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.
<Task commandLine="Startup.cmd" executionContext="limited" taskType="simple">
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.
-Life was much simpler when apple and blackberries were just fruits.
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.
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.
- Proposed as answer by Arora S Thursday, May 12, 2011 12:13 PM
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
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">
<Import moduleName="Diagnostics" />
<Variable name="MY_ENV" value="my_value" />
<Variable name="MY_SECOND_ENV" value="my_value2" />
Please let me know if you have any solution.Thanks