在azure中设置webapp%PATH%环境变量

时间:2016-07-25 19:00:43

标签: azure system-variable

我正在开发一个azure webapp项目。为了使我的应用程序正常工作,我需要在服务器上安装第三方开源软件。我发现在azure webapp上执行此操作的唯一方法是手动复制项目中软件的所有文件夹,然后添加所有必需的环境变量,并添加路径系统变量的几个路径。 我发现如何添加系统变量,但是我找不到在azure webapp上设置路径变量的方法。

1 个答案:

答案 0 :(得分:9)

您可以通过 XDT转换 X ML D 文章 T 转化)来实现这一目标。

查看https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

  

添加环境变量

     

以下内容将注入名为FOO的环境变量,其值为BAR,并向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>

将其放入d:\home\site\applicationHost.xdt,重新启动网络应用并检查Kudu中新修订的%PATH%https://sitename.scm.azurewebsites.net/DebugConsole)。

d:\home>set PATH
Path=D:\home\site\deployments\tools;[...];D:\home\BAR
相关问题