Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting the webapp %PATH% environment variable in azure

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.

like image 879
Farhad Avatar asked Jul 25 '16 19:07

Farhad


People also ask

How do I set an environment variable in Azure?

To set environment variables when you start a container in the Azure portal, specify them in the Advanced page when you create the container. Under Environment variables, enter NumWords with a value of 5 for the first variable, and enter MinLength with a value of 8 for the second variable.

How do I change my Azure Web app location?

The region in which your app runs is the region of the App Service plan it's in. However, you cannot change an App Service plan's region. If you want to run your app in a different region, one alternative is app cloning. Cloning makes a copy of your app in a new or existing App Service plan in any region.

Which URL must be used to manage the Azure web Apps?

When you create a new website by using Web Apps in Azure, a default sitename.azurewebsites.net domain is assigned to your site. If you add a custom host name to your site and don't want users to be able to access your default *. azurewebsites.net domain, you can redirect the default URL.


1 Answers

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
like image 129
evilSnobu Avatar answered Sep 21 '22 13:09

evilSnobu