setting the webapp %PATH% environment variable in azure
Asked Answered
B

1

8

I am working on an azure webapp project. In order for my application to work, I needed to install a third party open source software on the server. The only way that I found to do that on the azure webapp, was to manually copy all the folders of the software on my project and then add all the required environment variables and also add few paths to the path system variable. I found how I can add the system variables, but I could not find the way to set the path variable on azure webapp.

Billposter answered 25/7, 2016 at 19:0 Comment(0)
S
11

You can achieve that through an XDT Transform (XML Document Transform).

Check out https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

Adding environment variables

The following will inject an environment variable named FOO, with value BAR, and add a folder to the PATH:

<?xml version="1.0"?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
  <system.webServer> 
    <runtime xdt:Transform="InsertIfMissing">
      <environmentVariables xdt:Transform="InsertIfMissing">
        <add name="FOO" value="BAR" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />    
        <add name="PATH" value="%PATH%;%HOME%\BAR" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />    
      </environmentVariables>
    </runtime> 
  </system.webServer> 
</configuration>

Drop it in as d:\home\site\applicationHost.xdt, restart the Web App and check the freshly amended %PATH% in Kudu (https://sitename.scm.azurewebsites.net/DebugConsole).

d:\home>set PATH
Path=D:\home\site\deployments\tools;[...];D:\home\BAR
Stud answered 25/7, 2016 at 21:34 Comment(1)
That was exactly what I was looking for.Billposter

© 2022 - 2024 — McMap. All rights reserved.