Working with a team to see if we can do an Azure Install of DHIS2. I haven’t found any references or successful installations, so if you have one, or have links to more information we would be interested.
We are focusing on Azure since that is our primary cloud foundation and experience, as well as grants and non-profit pricing that we utilize. I’ve worked on basic cloud projects for a couple of years, I’m a beginner when it comes to DHIS2 however. I have a local DHIS2 server running on a VM I used to become familiar with he basic install process.
In absence of instructions for Azure, below is where I’ve started, although I don’t have a working install yet. We are working through the process to see if one can be setup, and then sharing the steps out to others that might be interested. I have found the installation information on AWS, but the process is a little different for what we are trying to do. You can use the information below as a starting point and share any lessons learned as you go if you’d like to help. If we are successful, I’ll publish the steps here for others to use and improve upon
Thought Process:
We could work from a VM with either an included PostgreSQL DB, or link to an Azure PostgreSQL DB. Preference is to keep the two separate, and have a very lightweight app service for the application. Ideally we would be able to use a Linux App Service which is small and light, but so far I have not had any success.
Basic Steps and what we are using:
Creating an “App Service + DB” which allows you to create a separate container for the App, and a database server in Azure. Starting with this allows you to do the majority of software setup, environment variables, and networking/firewall requirements as part of their Quickstart Template. At that point it should just be setting up the DHIS2 application on the App Service.
First, we created a Resource Group to hold all the resources that are created. Keeping them in one place, and only using the group for our DHIS2 Instance makes it much easier for changes and updates. Also to give permissions to other groups that may need access to the Infrastructure portion of the install.
When setting up the App Service + DB, the following selections are made:
- Subscription:
- Resource Group:
- Region:
- Name: will be accessed by .azurewebsites.net
- Runtime Stack: Java 11
- Java web server stack: Apache Tomcat 9.0
- DB Engine: PostgreSQL - Flexible Server
- Server name:
- Database name:
- Hosting: for practice testing
Will take several minutes to provision, but will create an App Server, DB Server, Virtual Networks/DNS. It will also create firewall rules to limit access to resources from the public, except for the App server which will be public facing by default.
To deploy the WAR file to the server, using the Azure CLI, type the following command:
az webapp deploy --resource-group --name --src-url <URL to the .WAR file release you want to install> --type war
I used https://releases.dhis2.org/2.38/dhis2-stable-latest.war as my URL above. make sure to include the “–type war” command at the end.
This command will download the .WAR file and place it in the correct location for Tomcat on the app service.
In the App Service, Configuration, it creates several ENV variables that can be used within the container This include DBSERVER, DBNAME, DBPASS among others. I also added a DHIS2_HOME variable with the link to the location for the config files.
Last I used Kudu SSH to go into the container and create the DHIS2_HOME folder as well as the dhis.conf file You can use the ENV variables within the dhis.conf file to build the connection string. Make sure to only save things in the /home directory. That is persistent between moves and reboots. changing files anywhere else may not persist. Also, make sure to restart the container when making changes so that they will take effect.
All of this got me two things.
- Accessing the App URL the first time I had a blank screen for awhile. But it ended up with a Tomcat 404 error eventually. This was similar to the behavior of an initial install locally, except that it ended at the login screen instead.
- Subsequent visits went straight to 404.
Still reviewing logs on both the app service and the DB server, but no clues so far.
Questions:
- The instructions talk about not running as root, but in these type of containers that is usually how they run them. Is there a particular security reason within DHIS2 itself that I wouldn’t want to do that?
- Is the startup.sh necessary? It looks like it starts Tomcat with DHIS2, but again in this case, I think the app service does that when it starts, especially using the “az deploy” cmd. Is there another reason why it would need a separate startup.sh? It is possible to run a script as part of the startup process of the service if needed.
Thanks in advance. I just wanted to put this out there to see if we could come up with a way to deploy DHIS2 on Azure in a quick, lightweight reproducible way.
Ken