I have a Docker-based Django application running on a Linux based Webapp in Azure, which can scale from 1-5 instances. I want to run cron-tabs which run management commands inside the Django application, and found the following approaches:
I've found this post, suggesting a bash-script to start the cron-tabs. How to run cronjobs on an azure linux hosted webapp?
I've also found this example github on how to set-up cron-tabs inside a docker-container: https://github.com/Adiii717/docker-python-cronjob
- But the problem is that I can't run it inside the Docker environment, as the cron-jobs then will be run multiple times if the Webbapp is scaled over multiple instances in Azure.
I neither can use Azure's Webjobs, as it's not yet available for Linux-based Webapps.
The only option I see right now is creating a parallell mirrored Webapp that's restricted to only using one instance from Azure, thus not creating the issue with having cronjobs being run multiple times - but this seems sub-optimal as I need to deploy two web-apps every time I make code change, to have both the "original" application as well as the "cronjobs-application" being run on the same updated version of the codebase.
How can I implement a better solution for this?
EDIT: I've seen that maybe Time triggered Azure functions could work for this: https://stackoverflow.com/a/57674619/17014863
However there is not that much information regarding this approach - for example - can I access the codebase inside my Docker-Django app from the function and from there invoke the management-commands in my Django-app?