在 azure 中设置 webapp %PATH% 环境变量
setting the webapp %PATH% environment variable in azure
我正在开发一个 azure webapp 项目。为了让我的应用程序运行,我需要在服务器上安装第三方开源软件。我发现在 azure webapp 上执行此操作的唯一方法是手动复制项目中软件的所有文件夹,然后添加所有必需的环境变量,并向路径系统变量添加一些路径。
我找到了如何添加系统变量,但我找不到在 azure webapp 上设置路径变量的方法。
您可以通过 XDT 变换 (XML D文件 T变换).
查看 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>
将其作为 d:\home\site\applicationHost.xdt
放入,重新启动 Web App 并在 Kudu (https://sitename.scm.azurewebsites.net/DebugConsole) 中检查新修改的 %PATH%
。
d:\home>set PATH
Path=D:\home\site\deployments\tools;[...];D:\home\BAR
我正在开发一个 azure webapp 项目。为了让我的应用程序运行,我需要在服务器上安装第三方开源软件。我发现在 azure webapp 上执行此操作的唯一方法是手动复制项目中软件的所有文件夹,然后添加所有必需的环境变量,并向路径系统变量添加一些路径。 我找到了如何添加系统变量,但我找不到在 azure webapp 上设置路径变量的方法。
您可以通过 XDT 变换 (XML D文件 T变换).
查看 https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples
Adding environment variables
The following will inject an environment variable named
FOO
, with valueBAR
, 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>
将其作为 d:\home\site\applicationHost.xdt
放入,重新启动 Web App 并在 Kudu (https://sitename.scm.azurewebsites.net/DebugConsole) 中检查新修改的 %PATH%
。
d:\home>set PATH
Path=D:\home\site\deployments\tools;[...];D:\home\BAR