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

Far*_*had 6 azure system-variable

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

evi*_*obu 9

您可以通过XDT变换(X ML D ocument T ransform )实现这一目标.

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

添加环境变量

下面将注入一个名为FOOvalue 的环境变量,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>
Run Code Online (Sandbox Code Playgroud)

将其放入d:\home\site\applicationHost.xdt,重新启动Web App并检查%PATH%Kudu中的新修改(https:// sitename .scm.azurewebsites.net/DebugConsole).

d:\home>set PATH
Path=D:\home\site\deployments\tools;[...];D:\home\BAR
Run Code Online (Sandbox Code Playgroud)