Skip to main content

Command Palette

Search for a command to run...

๐Ÿš€ Deploying SonarQube on Azure Ubuntu VM (Private IP Only) โ€” Enterprise Production Guide

Updated
โ€ข6 min read

Realโ€‘world DevOps implementation in a corporate Azure environment with private networking, PostgreSQL, NSG, and firewall troubleshooting.


๐Ÿ“Œ Introduction

In most enterprise environments, Azure Virtual Machines do not have public IP addresses due to strict security policies. Access is allowed only through:

  • VPN access ๐Ÿ”

  • Private IP networking ๐ŸŒ

  • Network Security Groups (NSG) ๐Ÿ›ก๏ธ

  • Corporate Firewall Rules ๐Ÿ”ฅ

Recently, I deployed SonarQube in my organization's Azure Dev environment on an Ubuntu VM with only a private IP.

During this setup, I faced multiple realโ€‘world production issues such as:

  • SonarQube not starting

  • PostgreSQL permission errors

  • Port not listening

  • NSG allowed but still inaccessible

  • Firewall blocking access

This blog explains the complete setup, troubleshooting, and production best practices.


๐Ÿงญ Quick Overview of Steps

Step Task Purpose
1 Connect to VM Access private Azure VM via SSH
2 Update system Install latest security updates
3 Install Java 17 SonarQube runtime dependency
4 Install PostgreSQL Production database
5 Create DB and user Dedicated secure database
6 Download SonarQube Install application
7 Create sonar user Run service securely
8 Configure sonar.properties Connect SonarQube to DB
9 Configure limits.conf Prevent memory issues
10 Configure sysctl Kernel tuning
11 Create systemd service Production service management
12 Configure Azure NSG Allow network access
13 Troubleshoot issues Fix DB and network problems
14 Access SonarQube Verify successful deployment

๐Ÿ—๏ธ Architecture

Developer Laptop

โ”‚

โ–ผ

Corporate VPN

โ”‚

โ–ผ

Corporate Firewall

โ”‚

โ–ผ

Azure VNet

โ”‚

โ–ผ

Azure Ubuntu VM (Private IP)

โ”‚

โ–ผ

SonarQube Service (Port 9000)

โ”‚

โ–ผ

PostgreSQL Database

โœ” No public exposure
โœ” Fully enterpriseโ€‘secured deployment


๐Ÿ” Step 1: Connect to Azure VM

Using PuTTY or SSH:

ssh azureuser@PRIVATE_IP


๐Ÿ”„ Step 2: Update System

sudo apt update && sudo apt upgrade -y

Always recommended in production.


โ˜• Step 3: Install Java 17

sudo apt install openjdk-17-jdk -y

Verify:

java -version

Check path:

readlink -f $(which java)

Example:

/usr/lib/jvm/java-17-openjdk-amd64/bin/java


๐Ÿ˜ Step 4: Install PostgreSQL

sudo apt install postgresql postgresql-contrib -y

Enable service:

sudo systemctl enable postgresql

sudo systemctl start postgresql

Check:

sudo systemctl status postgresql


๐Ÿ—„๏ธ Step 5: Create Database and User

sudo -i -u postgres

psql

CREATE DATABASE sonarqube;

CREATE USER sonar WITH ENCRYPTED PASSWORD 'StrongPassword';

GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonar;

\c sonarqube

GRANT ALL ON SCHEMA public TO sonar;

ALTER SCHEMA public OWNER TO sonar;

Exit:

\q

exit

โœ… This schema permission is critical in production.


๐Ÿ“ฆ Step 6: Download SonarQube

wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.5.0.89998.zip

sudo apt install unzip -y

unzip sonarqube-*.zip

sudo mv sonarqube-* /opt/sonarqube


๐Ÿ‘ค Step 7: Create Sonar User

sudo adduser --system --no-create-home --group --disabled-login sonar

sudo chown -R sonar:sonar /opt/sonarqube

Security best practice.


โš™๏ธ Step 8: Configure Database Connection

sudo nano /opt/sonarqube/conf/sonar.properties

Update:

sonar.jdbc.username=sonar

sonar.jdbc.password=StrongPassword

sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube


๐Ÿง  Step 9: Configure System Limits

sudo nano /etc/security/limits.conf

Add:

sonar - nofile 65536

sonar - nproc 4096


โšก Step 10: Configure Kernel Parameters

sudo nano /etc/sysctl.conf

Add:

vm.max_map_count=262144

fs.file-max=65536

Apply:

sudo sysctl -p


๐Ÿ”ง Step 11: Create Systemd Service

sudo nano /etc/systemd/system/sonarqube.service

[Unit]

Description=SonarQube

After=network.target

[Service]

Type=forking

User=sonar

Group=sonar

ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start

ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

Restart=always

LimitNOFILE=65536

LimitNPROC=4096

[Install]

WantedBy=multi-user.target

Enable:

sudo systemctl daemon-reload

sudo systemctl enable sonarqube

sudo systemctl start sonarqube

Check:

sudo systemctl status sonarqube


๐ŸŒ Step 12: Verify Port

sudo ss -tulnp | grep 9000

Expected:

LISTEN 0 128 0.0.0.0:9000


๐Ÿ” Step 13: Configure Azure NSG

Allow inbound rule:

Setting

Value

Source

Corporate CIDR

Destination

VM Private IP

Port

9000

Protocol

TCP

Action

Allow


๐Ÿšจ Real Production Issue #1: PostgreSQL Permission Error

Log location:

/opt/sonarqube/logs/web.log

Error:

permission denied for schema public

Fix:

GRANT ALL ON SCHEMA public TO sonar;

ALTER SCHEMA public OWNER TO sonar;

Restart:

sudo systemctl restart sonarqube


๐Ÿšจ Real Production Issue #2: Port Not Listening

Check:

sudo ss -tulnp | grep 9000

If empty โ†’ service failed.

Check logs:

cd /opt/sonarqube/logs

cat sonar.log

cat web.log


๐Ÿšจ Real Production Issue #3: Port Listening but Browser Not Opening

Situation:

โœ” Service running
โœ” Port listening
โœ” NSG allowed
โŒ Still inaccessible

Root Cause:

Corporate firewall blocked port.

Solution:

Requested network team to allow:

| Source | Corporate CIDR | | Destination | Azure VM Private IP | | Port | 9000 |

After firewall change โ†’ access successful.


๐ŸŒ Step 14: Access SonarQube

Open browser:

http://PRIVATE_IP:9000

Default credentials:

username: admin

password: admin


โœ… Production Best Practices

โœ” Always use PostgreSQL
โœ” Never expose public IP
โœ” Use NSG + Firewall
โœ” Run as dedicated user
โœ” Use systemd service
โœ” Monitor logs regularly


๐Ÿงช Troubleshooting Checklist

Issue

Command

Service status

systemctl status sonarqube

Port check

ss -tulnp

Logs

/opt/sonarqube/logs

DB issue

psql

Network issue

NSG + Firewall


๐ŸŽ‰ Final Result

Successfully deployed SonarQube in enterprise Azure environment with:

โœ” Private networking
โœ” PostgreSQL backend
โœ” Secure firewall access
โœ” Productionโ€‘ready configuration


โœ๏ธ Conclusion

Deploying SonarQube in enterprise environments involves more than installation. You must understand:

  • Linux configuration

  • Database permissions

  • Azure networking

  • Firewall layers

  • Service management

This experience helped me understand realโ€‘world DevOps troubleshooting in secure enterprise infrastructure.


๐Ÿ”— Connect With Me

If you found this helpful, follow me for more DevOps, Azure, AWS, SonarQube, and GenAI content.

Happy Learning ๐Ÿš€