我正在开发一个Azure Web应用项目。为了让我的应用程序正常工作,我需要在服务器上安装第三方开源软件。我在Azure Web应用中找到的唯一方法是手动复制该软件的所有文件夹到我的项目中,并添加所有必需的环境变量,还需要将几个路径添加到路径系统变量中。 我已经找到了如何添加系统变量,但我无法找到在Azure Web应用中设置路径变量的方法。
我正在开发一个Azure Web应用项目。为了让我的应用程序正常工作,我需要在服务器上安装第三方开源软件。我在Azure Web应用中找到的唯一方法是手动复制该软件的所有文件夹到我的项目中,并添加所有必需的环境变量,还需要将几个路径添加到路径系统变量中。 我已经找到了如何添加系统变量,但我无法找到在Azure Web应用中设置路径变量的方法。
添加环境变量
以下代码将注入名为
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
,重新启动 Web 应用程序并在 Kudu (https://sitename.scm.azurewebsites.net/DebugConsole) 中检查新修改的 %PATH%
。
d:\home>set PATH
Path=D:\home\site\deployments\tools;[...];D:\home\BAR