projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.13k stars 652 forks source link

Webjob Start/Stop unavailable when WEBSITE_RUN_FROM_PACKAGE=1 #3110

Closed AntonChernysh closed 4 years ago

AntonChernysh commented 4 years ago

Start/Stop kudu API endpoints are missing for Continuous WebJob when WEBSITE_RUN_FROM_PACKAGE is set to 1 api/continuouswebjobs/My.WebjobName/stop api/continuouswebjobs/My.WebjobName/start IT returns 404 when _WEBSITE_RUN_FROMPACKAGE=1 and works just fine when _WEBSITE_RUN_FROMPACKAGE=0 or completely removed.

Is this expected behavior? What is the best way to stop/start jobs in this scenario?

suwatch commented 4 years ago

Unfortunately this is the limitation for WEBSITE_RUN_FROM_PACKAGE = 1. Remove WEBSITE_RUN_FROM_PACKAGE and redeploy. However, if you must use WEBSITE_RUN_FROM_PACKAGE = 1, to stop/start the job, open d:\home\site\data\sitepackages\packagename.txt and point it to empty zip file with just default.html etc - this will represent no jobs. Switch it back if you want the job to get started. I understand it is a hack but should unblock you.

AntonChernysh commented 4 years ago

@suwatch thanks for explaining.

NeilMcKLogic commented 4 years ago

Thanks @suwatch , this solved a mystery I've been working on for several days. Silly question though: How do I edit the file d:\home\site\data\sitepackages\packagename.txt ? Is there a tool in the Azure Portal, in Visual Studio, or in KUDU to use? I can navigate some of the file structure via Cloud Explorer but it does not show me it from the perspective of the D:\ drive.

NeilMcKLogic commented 4 years ago

@suwatch nevermind, I found the DebugConsole in KUDU. When I pointed packagename.teext to an empty zip file, the webjobs all disappeared from the portal (expected) but also when I made the REST API call to stop the webjob, I still get a 404, because I have no WebJobs deployed there manually.

What I'm hoping to do is stop the Webjob that was deployed from WEBSITE_RUN_FROM_PACKAGE = 1 so it sounds like your workaround won't work. I'd love to be wrong though, please let me know if I am.

suwatch commented 4 years ago

Thanks for trying various things. It is the limitation. BTW, I consult our wiki (https://github.com/projectkudu/kudu/wiki/WebJobs#configuration-settings). Did you try to set the appSettings WEBJOBS_STOPPED = 1?

NeilMcKLogic commented 4 years ago

This is awesome, @suwatch thanks for sharing. I had not come across this documentation in my normal searching.