Setting / Getting System Variables on Azure Web Roles
<p>I can't believe I am the only person to have come across this issue, but I am not able to find anything about it anywhere.</p>

<p>We currently have some Azure Web Roles running our app, and for security I decided to put credentials like usernames, passwords and API keys in the System Environment Variables, and get them in my PHP scripts using <code>getenv()</code>.</p>

<p>We are running Windows Server Web Roles with IIS and PHP installed. I am using a startup task in my <code>ServiceDefinition.csdef</code> like so:</p>

<pre><code>&lt;Startup&gt;
  &lt;Task commandLine="setEnvironmentVariables.cmd" executionContext="elevated" /&gt;
&lt;/Startup&gt;
</code></pre>

<p>The contents of the <code>cmd</code> file simply sets the environment variables when the web role is spun up.</p>

<p>So far so good. However I know from experience on our windows dev server, that in order for PHP scripts to see newly added environment variables, you have to run <code>IISReset</code>, you can then see them using <code>getenv()</code>.</p>

<p>However you cannot run <code>IISReset</code> on Azure web roles, as per this document here <a href="https://azure.microsoft.com/en-us/blog/iis-reset-on-windows-azure-web-role/" rel="nofollow noreferrer">https://azure.microsoft.com/en-us/blog/iis-reset-on-windows-azure-web-role/</a></p>

<p>So my scripts cannot see the variables!! Am I missing something, or is there an easier way to set the system environment variables when the web role starts so that PHP can see them?</p>