Deploy a SonarQube instance to Azure Container instances connected to Azure SQL & Azure Storage
location: The location of the resource group.storageAccountName: The name of the storage account to use as the persistence layer.containerInstanceName: The name of the container instance to use as the SonarQube host.dnsName: The DNS name for the SonarQube instance.sqlServerName: The name of the Azure SQL Server to use for SonarQube.sqlDatabaseName: The name of the Azure SQL Database to use for SonarQube.sqlServerAdminLogin: The database login for SonarQube.sqlServerAdminPassword: The database password for SonarQube.dockerHubUsername: Docker Hub username for container image authentication.dockerHubPassword: Docker Hub password or access token for container image authentication.
The storage account is used to persist the data for the SonarQube instance.
The Azure SQL Server and Database are used to store the SonarQube data.
This deployment contains two container instances.
sonarqube-container: This container runs the SonarQube instance. It should be configured to connect to the SQL database and the storage account. It also has volume mounts for configuration, data, logs, and extensions.caddy-container: This container runs the Caddy web server. It is used to provide HTTPS termination for the SonarQube instance. It is also configured with a volume mount for the Caddy data.
- Docker Hub account with username and password/access token
- Azure subscription and resource group
az deployment group create \
--resource-group <your-resource-group> \
--template-file src/main.bicep \
--parameters sqlServerAdminPassword="<your-secure-password>" \
dockerHubUsername="<your-dockerhub-username>" \
dockerHubPassword="<your-dockerhub-password>"To deploy this template using the Azure Portal, you have several options:
Click the button below to deploy directly from GitHub:
This will:
- Open the Azure Portal with the template pre-loaded
- Prompt you to select a subscription and resource group
- Ask you to provide the required parameters (including Docker Hub credentials)
- Deploy the resources
- Go to Azure Portal
- Search for "Deploy a custom template" or navigate to Create a resource → Template deployment (deploy using custom templates)
- Click Build your own template in the editor
- Either:
- Upload file: Select the
main.jsonfile from this repository - Load file: Copy and paste the contents of
main.bicep
- Upload file: Select the
- Click Save
- Fill in the required parameters:
- sqlServerAdminPassword: A secure password for your SQL Server (min 8 chars, must include uppercase, lowercase, number, and special character)
- dockerHubUsername: Your Docker Hub username
- dockerHubPassword: Your Docker Hub password or access token (recommended)
- Select your subscription and resource group
- Click Review + create then Create
- Update the
main.parameters.jsonfile with your actual values - Follow steps 1-4 from Option 2
- Click Load parameters file and upload your updated
main.parameters.json - Review the auto-filled parameters and proceed with deployment
Note: Due to Docker Hub's authentication requirements, you must provide valid Docker Hub credentials during deployment. You can use either your Docker Hub password or an access token (recommended for better security).
You can also use the provided main.parameters.json file as a template:
az deployment group create \
--resource-group <your-resource-group> \
--template-file src/main.bicep \
--parameters @src/main.parameters.jsonMake sure to update the parameter values in the file before deployment.
For production deployments, it's recommended to store sensitive information like passwords in Azure Key Vault. Use the main.parameters.keyvault.json template:
az deployment group create \
--resource-group <your-resource-group> \
--template-file src/main.bicep \
--parameters @src/main.parameters.keyvault.jsonBefore using this approach:
- Create an Azure Key Vault
- Store your SQL admin password and Docker Hub password as secrets
- Update the Key Vault ID in the parameters file
- Ensure your deployment principal has access to the Key Vault