2

I am trying to set up Drush9 for Drupal8. I was able to get my site up and running using the site extensions to install composer and the Drupal installer, but now there is a Drupal update and I want to be able to perform the update through the Azure app service Kudu cmd console ([AppName].scm.azurewebsites.net).

I am following the Drupal update guide and am able to update the Drupal files using composer, but the drush database update (drush updb) fails due to mysql not being registered to the PATH.

screenshot of error

I tried running SETX PATH "D:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe" which is where the mysql.exe is located, but get an access denied.

Has anyone else had success adding an exe to the PATH, or have any other methods.

Thanks

Jake
  • 205
  • 1
  • 9

3 Answers3

2

You could add a App settings to you web app, like below:

enter image description here

Then, restart your web app, in Kudu console, you could check it.

enter image description here

Also, you can achieve that through an XDT Transform (XML Document Transform).

See this question.

Shui shengbao
  • 3,503
  • 1
  • 10
  • 20
  • I tried adding the App Setting and including the necessary nodes in the web.config but unfortunately I am still getting the same error. – Jake Jan 16 '18 at 03:18
  • When you execute `env|find mysql` could you see it, if possible, I suggest you could second method. You install 3rd service on Azure web app. – Shui shengbao Jan 16 '18 at 03:20
  • Yes, it shows up with a `env|findstr mysql` the same way it does in your screenshot above. Not sure I understand what you mean by `install 3rd service on Azure web app` I added a screenshot to the original post to show the error message I am getting. – Jake Jan 16 '18 at 03:24
  • Hi, it this method does not work for you? Check this [link](https://social.msdn.microsoft.com/Forums/en-US/c94ac251-dce2-4667-975f-3c8c7a3696e6/system-path-environment-variable?forum=windowsazurewebsitespreview) I think it should work for you. This is same with my second method. Hope it helps. – Shui shengbao Jan 16 '18 at 04:04
  • https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples – Shui shengbao Jan 16 '18 at 04:05
  • I update my answer. – Shui shengbao Jan 16 '18 at 04:07
  • Using the above method was on the right track, but because I also had Composer installed through a site extension it had some conflict/override thing happening. I took what you offered as a starting point and was able to get a solution to my specific problem – Jake Jan 17 '18 at 23:29
2

It turns out that because I also had the composer site extension installed, it has its own applicationHost.xdt which was overriding the root level one or causing a conflict.

I ended up creating a D:\home\site\applicationHost.xdt file with the following contents:

<?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="PATH" value="%PATH%;%HOME%\SiteExtensions\ComposerExtension\Commands;%APPDATA%\Composer\vendor\bin;d:\Program Files\MySQL\MySQL Server 5.1\bin" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
        <add name="PATH" value="%PATH%;%HOME%\SiteExtensions\ComposerExtension\Commands;%APPDATA%\Composer\vendor\bin;d:\Program Files\MySQL\MySQL Server 5.1\bin" xdt:Locator="Match(name)" xdt:Transform="Replace" />
      </environmentVariables>
    </runtime>
  </system.webServer>
</configuration>

This keeps both the environment variable stuff Composer adds as well as allowing me to extend the PATH with the new directory.

Hopefully this helps someone else with a similar issue in the future.

Jake
  • 205
  • 1
  • 9
0

You can do this to add the mysql client to the path in PowerShell:

$MysqlClientVersion=(Get-ChildItem -Name "D:\Program Files (x86)\mysql\" | Select-String -Pattern "^[\d.]+$" | % { $_.Line }) $Env:PATH += ";D:\Program Files (x86)\mysql\$MysqlClientVersion\bin"