How to set the PATH on an Azure App Service, customize, modify

The location from which a process is invoked is important.  A process, I.e. an executable (.exe) is the program which contains the entry point to the code which needs to run.  If the location is in a relative position related to the assemblies it requires, then the .exe can use relative paths to access an load them at runtime.  Consider that I have a process which stores its dependent assemblies in a directory location like the following.

D:\home\SiteExtensions\theBestSiteExtensionEver

Then consider that the process which needs the assemblies in that directory location is instantiated in this directory.

D:\home\site\wwwroot

That process will not know anything about where TheBestSiteExtensionEver assemblies are located.  The way in which you provide this information is using the PATH Environment variable.  You can view the current values for PATH in KUDU/SCM, either from the Environment page or by running SET PATH via the CMD Debug console.

image

Figure 1, How to set the PATH environment variable on an Azure App Service / Function windows

image

Figure 2, How to set and view the PATH environment variable on an Azure App Service / Function windows

I have written a few articles about using XDT transformation to make changes to the IIS configuration on which Azure App Services and Azure Function Apps run.  Here are a few:

So, you guessed it, the way to make this happen is to use XDT transformation.

Here is a copy of the XDT file I used, to achieve the following.  CAUTION: don’t perform such actions like this directly into production, because if you somehow have a typo, miss something or leave something out, it can have sever consequences to your site, possibly requiring a re-provision and redeployment.  Perform this on a test environment or a slot before moving it into production.

After adding the XDT file to the D:\home\site directory and restarting the site, I see the path which should let my process load the required binaries/assemblies.

image

Figure 3, How to set and view the PATH environment variable on an Azure App Service / Function windows

image

Figure 4, How to set and view the PATH environment variable on an Azure App Service / Function windows