Setting up a SonarQube Server in Azure

To get started with using SonarQube in Azure, do the following.

Create a virtual machine with the Standard B2s (~$30/month) size or larger.

SSH into the server and download all pre-reqs:

Create a non-root user:

Download and unzip SonarQube (you can get the wget URL from the Downloads page):

Then start it using the following as the non-root user:

Wait for the text SonarQube is up and then verify access at IP_ADDRESS:9000 (you can log in with admin/admin).

Set Up PostgreSQL

Next step is setting up a dedicated database – we will use PostgreSQL to accomplish this.

Install PostgreSQL:

And connect into the server instance and run the following commands:

Now modify /opt/sonarqube/conf/

Add the following line to /etc/sysctl.conf:

To finish, restart the server, start up SonarQube again and verify that it can start up successfully, alongside having the “embedded DB” warning removed from the login screen.

Set to Run As A Service On VM Start

Next, we’ll set up the ability to start SonarQube on VM start by running SonarQube as a service.

Add the following file /etc/systemd/system/sonarqube.service:

Then enable and start the service:

Confirm by restarting the server and checking that SonarQube is running.

Setting up Reverse Proxy and HTTPS with Let’s Encrypt

Next step is setting up HTTPS, in this case we’ll use Let’s Encrypt for the certificate. To serve the correct ports, we’ll set up Apache and serve it as a proxy to the built-in Tomcat server that SonarQube provides.

When looking to configure Apache, set up the pre-reqs:

Add these lines to /etc/apache2/sites-enabled/000-default.conf:

Restart Apache:

And check that you can access SonarQube using port 80 (HTTP).

Once port 80 is accessible, you can follow the Certbot steps to enable HTTPS.

Next Steps