setting the webapp %PATH% environment variable in azure

与世无争的帅哥 提交于 2019-12-08 19:32:09

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/38575557/setting-the-webapp-path-environment-variable-in-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!