Setup¶
Running Locally¶
The function apps are typically deployed automatically via Pulumi (see the RCTab Infrastructure docs). However, it is easy to run them locally for development. The general process to install dependencies and run the function apps is outlined below but you should also check each function app’s page in case there are more specific requirements.
Pre-requisites¶
Install poetry. This is used to manage virtual environments and package dependencies.
Install pyenv (e.g. with
brew install pyenv). This is optional but useful for matching Python versions between development and production.See here for more detailed instructions.Install pre-commit (e.g. with
brew install pre-commit). This is used to run linters and other static checks during Git commits.
Setup¶
cdinto the function app’s directory.Install the requirements with
pyenv local 3.10.xto set the local Python version with pyenv to match that inpyproject.toml.poetry env use $(which python)to tell Poetry the Python version to use.poetry installto install dependencies into a new Poetry environment.poetry shellto activate the new environment.
Set the host or IP of the listening RCTab web server, which will probably be a local one. For example,
export API_URL=http://127.0.0.1:8000. Note, avoid usinghttp://localhost:8000as Pydantic will produce a URL validation error about missing top level domain.Set an environment variable called
RCTAB_TENANT_ID, which should contain your organisation’s Azure Active Directory tenant ID.Generate a public/private key pair with
ssh-keygen -t rsa. Set an environment variable calledPRIVATE_KEYwith the contents of the private key file, for example,export PRIVATE_KEY=$(cat /path/to/private/key/file). You will need to provide the public part of the key pair to the RCTab API.
Note Instead of setting the environment variables in the terminal, you can put them in a .env file.
Run¶
Make sure that the right Poetry environment is activated.
Run the function with
python run_now.py.
Running on Azure¶
Setup¶
You should create function apps on Azure using by deploying RCTab with the Infrastructure repo. By default, functions deployed this way will pull the latest RCTab images from DockerHub. If you want to deploy custom code to your function apps, you will need a container registry, which you can get by signing up to DockerHub or by setting up an Azure Container Registry. You can either build and push images to your registry manually or by forking the functions repo and using the deployment GitHub workflow.
Run¶
The function app will run according to the cron expression in its
function.json.You can force the function to run by following these instructions. Or, if you are using httpie, by running:
http POST https://your-function-app.azurewebsites.net/admin/functions/function-name '{APP_KEY}' 'Content-Type:application/json' input=test
where APP_KEY is the
_masterkey at portal.azure.com -> your-function-app -> “App keys” -> “Host keys”.