How to Use Azure Automation to Update Uptime Kuma

Last year I wrote about Uptime Kuma and what an awesome and simple tool it was for monitoring uptime on your network resources. I love the fact that it has active development behind it, and that patches are released regularly, but I find myself having a hard time keeping up with it. Now admittedly, I’m no Linux expert, and I don’t have anything in my environment like Ansible. However, I am a fan of Azure Automation. This ended up tickling that part of the brain that had me wondering if I could automate those updates.

Now full disclosure, there is probably a better way to do this. I went for something quick and dirty yet effective, so I’m open to suggestions on how this could be approved. Regardless, it works, and I thought it might be interesting to share it with the rest of the world. So here we go.


Please understand that the content herein is for informational purposes only. This existence and contents shall not create an obligation, liability or suggest a consultancy relationship. In further, such shall be considered as is without any express or implied warranties including, but not limited to express and implied warranties of merchantability, fitness for a particular purpose and non-infringement. There is no commitment about the content within the services that the specific functions of the services or its reliability, applicability or ability to meet your needs, whether unique or standard. Please be sure to test this process fully before deploying in ANY production capacity, and ensure you understand that you are doing so at your own risk.

Table of Contents

Original Update Process
Script to Update Uptime Kuma

Original Update Process

Ok so I followed the Docker Compose instructions for setting up Uptime Kuma. This basically means that updates are actually super simple. Now I am not a Docker expert, and I don’t have any experience with managing Docker beyond one or two applications. Its personal stuff, and small scale so I don’t worry about taking things down when I want or worrying about downtime. I also don’t use any additional tools with Docker to make management easier. I know they exist; I just haven’t tried any.

As a result, here has been my process for updating Uptime Kuma thus far:

#Step one - change directory
cd mykuma

#Step two - pull the latest docker compose image
sudo docker compose pull

#Step three - recreate the docker app and relaunch it disconnected from the session
sudo docker compose up -d --force-recreate

See? Pretty simple. Even still, it requires I log in and run each step manually. I’m an IT guy, so that means I believe (for better or worse) that I need to make my job simple whenever possible. So why not automate even this simple task right?

How am I supposed to automate this?

After some consideration, I figured I needed to do 4 things:

  1. Connect the Ubuntu Host to Azure Arc.
  2. Turn it into a Hybrid Worker.
  3. Write the automation script in python.
  4. Set the automation to run the script locally on the hybrid worker, on a schedule.

So that is exactly what I did. I’ve covered each of these steps individually in other posts, and I’ve linked them above. I included the Microsoft instructions for adding a Linux host to Azure Arc, though it’s the same process as adding a Windows Server Core machine. Just different syntax. I also scheduled mine to run weekly, though you can decide how often you want yours to check. If you’ve done these steps before, there it shouldn’t be too hard, but those are all the instructions if you get stuck.

Script to Update Uptime Kuma

Normally, if you’ve been here a while, you probably would expect this next part to be a PowerShell script. Well, I’ve branched out! My wife took a class on Python for school, and as I was helping her out with it, I found Python to be fun to play with. I had to do some Google-Fu to make this work, but we did it. First ever Python script posted on!

#!/usr/bin/env python3

#import required modules
import subprocess

#define the function to update the Uptime Kuma Docker Compose and launch it
def update_container():
    # Step 1: Change directory to 'mykuma'
    mykuma_directory = "/home/smitty/mykuma""cd {mykuma_directory}", shell=True)

    # Step 2: Pull the latest images"sudo docker compose -f /home/smitty/mykuma/docker-compose.yml pull", shell=True)

    # Step 3: Recreate and bring up the containers"sudo docker compose -f /home/smitty/mykuma/docker-compose.yml up -d --force-recreate", shell=True)

    # Step 4: Display Running Docker Containers"docker ps -a", shell=True)

if __name__ == "__main__":

Ok so the script isn’t that fancy. Essentially, I took my original process, and turned it into a Python function. I don’t think Step 4 is necessary, but since Azure Arc will save the output for previous runs, I thought it would be worth adding it. That way I could look back and see it was successfully restarted. When I get better at Python and Docker I may find a better way. Or if you know a better way, please feel free to let me know!

sample output for update kuma azure arc updates


There you have it, quick and simple. I intend to revisit this as I learn more about Python and get better at it. I’m almost certain there is a better way to do this. Either way this works for me. This script and process would definitely work for any other Linux hosted docker container as well. You would just need to change the docker compose directory and you are good to go. Realistically you could do it with any docker container, as long as you had the full set of bash commands.

I think long term, it’d be interesting to see how you could set a trigger on that GitHub and have it update based on when updates are released rather than on a schedule. This way you don’t need to run the updates needlessly. I also think it’d be interesting to add a webhook to Discord or Teams. There are clearly still opportunities for improvement.

There you have it! I hope you found this interesting. Let me know what you think! I’m still new to Python and Docker, so any suggestions would be greatly appreciated. Hit me up on Twitter @SeeSmittyIT to let me know what you thought of this post. Or if you are avoiding the bird site, I’m also posted up on Mastodon @[email protected]. Thanks for reading!


Curtis Smith works in IT with a primary focus on Mobile Device Management, M365 Apps, and Azure AD. He has certifications from CompTIA and Microsoft, and writes as a hobby.

View all posts by Smitty →