Use this project and workflow to run raw Python directly in Azure Functions. This is similar to my RewstPS project.
-
Fork this repository.
-
Create a Function App in Azure. You'll want to the latest version of Python and Linux as your operating system..
-
In your Function App in Azure, go to Deployment Center and connect it to the forked GitHub repository.
-
In Overview, copy your URL. We'll use this later to setup our Custom Integration. It will look like the following: https://yourfunctionapp.azurewebsites.net/api/run.
-
Navigate to your function app in Azure, then go to Overview. Under functions, click ScriptRunner.
-
Under Function Keys, copy your default key. We'll also be using this in the Custom Integration.
-
In Rewst, navigate to Configuration > Integrations > Custom Integrations. Add a new one called "Rewst Python" and match the settings below:
Hostname API Key Authentication Method API Key Header Name yourfunctionapp.azurewebsites.net The key you copied API Key x-functions-key -
Import the
run-python.bundle.json
file as a new workflow. -
In the
run_script
action under Advanced, you may need to add an Integration Override for your new Rewst Python integration as well and then click publish.
- Create a Python script under Scripts in Rewst. If you want to return results, assign something to a variable named
rewst_response
. - Open the
Run Python
workflow and click Test. - For script content, enter select your test script.
- See your result in
RESULT.result
.
If you wish to use any packages, you'll need to put them in a requirements.txt
file in your own repo. Currently, there's an issue I haven't had time to fully diagnose where GitHub Actions won't deploy a package with the required packages. A workaround would be to instead use Azure Functions Tools and deploy locally. The high-level process is:
- Install Azure Functions Tools.
- Run
func azure functionapp publish YOUR_APP_NAME --python
from the root of your forked repo.