Deploy Sonarqube on Azure Webapps using a Docker container for a simple and efficient setup.
Tags: azure, devops, docker, sonarqube
Published: 2023-10-19 17:00:20

---
title: Deploy Sonarqube on Azure Webapps using a Docker container for a simple and efficient setup.
published: true
date: 2023-10-18 18:38:35 UTC
tags: Azure,DevOps,Docker, Sonarqube
canonical_url: https://blog.bajonczak.com/deploy-sonarqube-on-azure-webapps/
---

 ![Deploy Sonarqube on Azure Webapps using a Docker container for a simple and efficient setup.](https://images.unsplash.com/photo-1511376777868-611b54f68947?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTc3M3wwfDF8c2VhcmNofDd8fGRldmVsb3B8ZW58MHx8fHwxNjk3NjU0MDA1fDA&ixlib=rb-4.0.3&q=80&w=2000)

Sonarqube is a nice program, so we use it in our development process. We "can" install it in our development environment but can host it on a server. The Server must not be a virtual machine, so I used an Azure Webapp running a container. Let me show how I did this with azure SaaS solutions.


#Create a SQL Server Database

Of course, you can use every database for this, but I want to use an SQL Server Database for this example. So let's create a Database in Azure, you can choose a plan that fits your needs.

> Important! Use the collation SQL\_Latin1\_General\_CP1\_CS\_A

After SQL database creation you must fetch the correct JDBC connection string

![Deploy Sonarqube on Azure Webapps using a Docker container for a simple and efficient setup.](https://blog.bajonczak.com/content/images/2023/10/image-19.png)

#Create a user and configure the database

After the creation of the Database, you can set up a specific user for the Database.

So on your master Database on the server, you must execute the following command

```
CREATE LOGIN sonarqube WITH PASSWORD = ‘StrongPassword’;
```

This will create the user s_onarqube_ on the database server. No switch to the sonarqube database in this you must execute the following script

```
CREATE USER sonarqube FOR LOGIN SonarQube WITH DEFAULT_SCHEMA = dbo;
ALTER ROLE db_owner ADD MEMBER sonarqube;
```

This will assign the user sonarqube to your database, and it will apply the db\_owner rights to him. For now, you can log in with this user to the database.

Now you must execute the following

```
ALTER DATABASE sonarqube SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;
```

This will set the READ\_COMMITED\_SNAPSHOT on every transaction on the database. This is required to get the maximum performance on this application.

#Configuring the Webapp

I use the sonarqube official image to run the sonarqube instance. For this, I must use the docker-compose deployment feature

![Deploy Sonarqube on Azure Webapps using a Docker container for a simple and efficient setup.](https://blog.bajonczak.com/content/images/2023/10/image-18.png)

In this, I will place the following YAML definition

```
version: "3.3"
services:
  sonarqube:
    image: sonarqube:lts-community
    ports:
      - "9000:9000"
    environment:
      - SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true
      - SONAR_JDBC_USERNAME=YOUR DB USER
      - SONAR_JDBC_PASSWORD=YOUR DB PASSWORD
      - SONAR_JDBC_URL= YOUR JDBC CONNECTIONSTRING;

```

This will install the community version that will be long-term supported. It will also expose the right port to use it against your webapplication. The environment variables will be used to configure the database connection.

Additionally, you must set the username and password too.

#Let's Run!

Now open up the webpage and it will take a while to load because it will load the image, start it, and install the database.

After waiting a while you will be prompted with a nice login like this

![Deploy Sonarqube on Azure Webapps using a Docker container for a simple and efficient setup.](https://blog.bajonczak.com/content/images/2023/10/image-20.png)

#Final words

To be honest, I tried several howtos that use the Webbapp configuration, using custom images or custom startup scripts. Yes there was a solution the would install the sonarqube onto the server, but I wanted a container solution. So I ended up in this, I think that it will be the best solution for my needs.

* * *

Did you like this article? Then maybe you can send me some [Ko-fi](https://ko-fi.com/abenteuerimkern?ref=blog.bajonczak.com)