1

This may be a very basic question but forgive me, I am a week old in AZURE. I have built a webjob and it executes my basic python scripts quite well within my service app interactive window in Azure portal. I call them basic python scripts because they import no specialized modules. I have more complex python scripts which are currently scheduled in windows scheduler and would like to get them managed within webjobs. The scripts import multiple python libraries including specialized spatial ones.

In the windows task scheduler I direct them to be executed by a set cloned environment which has all relevant packages installed.

  1. How can I do this in webjobs on a VM?
  2. All I have got concerning getting started with webjob SDKs is this article with everything done in C# in which I have no experience. Can someone direct me to a python resource that does the same if it exists.

See what I have tried

enter image description here

When I check in the logs this is what I get

enter image description here

Usually the modules that cannot be found are in a cloned envirnment which I direct the windows scheduler to read from. How do I do this in webjobs?

wwnde
  • 26,119
  • 6
  • 18
  • 32

1 Answers1

2

UPDATE

enter image description here

You should put all the content in your site-packages folder and your CentroidsDload.py file together into a zip file for uploading.

For more details, you can refer to this post.

Running Python script from Azure WebJob

  1. You can't do this webjob in a VM.

If you have a vm, you can host your web in iis. And you can run all programs you want. These have nothing to do with webjob, which is a concept in webapp.

  1. You should not pay attention to webjob sdk related content, as long as your script or program can run normally, upload it.

WebJob is an extended function of App Services under the Windows platform.

You can upload your scripts or programs as background processes in the context of your app.

enter image description here

enter image description here

Jason Pan
  • 15,263
  • 1
  • 14
  • 29
  • I did all this and it went fine. Except I had no way to instruct webjobs to call the env in which the relevant libraries were installed. The script couldnt run and it threw errors. What I am trying to find out is how I can fix this? Please see my edits. – wwnde Oct 23 '20 at 06:23
  • https://stackoverflow.com/questions/57830172/running-python-script-from-azure-webjob This post should useful to you. – Jason Pan Oct 23 '20 at 06:25
  • You can create env ,and make sure your program can run successfully, and package it. – Jason Pan Oct 23 '20 at 06:27
  • Because you use other extended modules in your project, only basic modules are included in azure, so you must need `env`. – Jason Pan Oct 23 '20 at 06:30
  • Will accept as soon as I am there. I believe I will get it going – wwnde Oct 23 '20 at 07:54
  • Didnt finish last week. I resumed today and I am stuck on step 4 where it states `The D:\home\python364x86\python.exe path is the python364x86 `. Not getting that file directory right. Is it where python is installed on my pc? – wwnde Oct 26 '20 at 02:23
  • From the path, yes. – Jason Pan Oct 26 '20 at 02:26
  • Thats what I use but I get `D:\local\Temp\jobs\triggered\ArcTrial\u54j2sxu.1l1\webjob>C:\Users\EdnArcGisAdmin\AppData\Local\Programs\Python\Python38\python.exe CentroidsDload.py [10/26/2020 02:17:53 > 3587fd: SYS INFO] Status changed to Failed [10/26/2020 02:17:53 > 3587fd: SYS ERR ] Job failed due to exit code 1` are you happy to start a chat? – wwnde Oct 26 '20 at 02:28
  • I get the path by running `where python` in the cmd – wwnde Oct 26 '20 at 02:29
  • What do you mean, how do I get that path?. If you were to replicate it on your pc, how would you get it? – wwnde Oct 26 '20 at 02:31
  • 1. `C:\Users\Administrator>python` 2. import sys 3. print(sys.path) – Jason Pan Oct 26 '20 at 02:34
  • This is what I use to acquire the path `import os import sys print(os.path.dirname(sys.executable))` – wwnde Oct 26 '20 at 02:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/223605/discussion-between-jason-pan-and-wwnde). – Jason Pan Oct 26 '20 at 02:38