简体   繁体   中英

Run PHP script after Azure Web app deployment

I am having an Azure app Service and I want to upload/deploy an.php file to it an run it right after the upload.

I managed to upload it via curl and also start a post deployment script. Unfortunately I can not use the command "php..." in it because I get an error like: "/opt/Kudu/Scripts/starter.sh: line 2: exec: php: not found\n" in the logs. The same occurs if I use the "/api/command" endpoint with the same command. I get the same kind of error in the response.

It seems like the php executable is not known in that environment. Is there any way to run a php script via the command API or in a post deployment script?

EDIT for further clarification: I need curl because I want to run it automatically with a deployer which generates a php file which then does our specific deployment tasks (generating folders, symlinks and so on). So after I deploy that php file on the App service I need to start it. So far curl was the only opportunity I found which doesn't need a user interaction if done correctly. With right after the upload I mean after using one of the 2 SCM/Kudu apis which are "/api/zip/" or "api/zipdeploy/"

Thanks in advance

  • You can use WebJob for running the scripts in Azure App Service Instance without any user interactions or which acts as background tasks.

  • Azure WebJobs SDK is to simplify many programming tasks.

  • The file types (scripts or programs) supported by Azure WebJobs SDK are: .cmd, .bat, .exe, .ps1, .sh .php , .py, .js, .jar

  • Just tweak your php script to have a loop and add a sleep of a few minutes between runs of your code.

  • The continuous WebJob will run on all of your instances and even if something fails it will be brought back up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM