This article will show how to deploy SQL Server 2019 on the Azure container instances using the Azure portal.
The Containers are a popular way of packaging, deploying, and managing cloud applications. It is a quick, reliable way to deploy your applications and databases without managing any virtual servers. Therefore, it is the standard unit of software, application with all dependencies in a lightweight, standalone, executable package to run platform-independent applications.
The container also solves the problem for developers where they need an isolation environment and do not want to spend time on SQL Server installation, upgrades. You can deploy containers and start using them quickly.
Image reference: docker.com
In the article, SQL Server 2019 on Linux with a Docker container on Ubuntu, we explored the docker container for SQL Server 2019. The Azure cloud infrastructure is a popular choice for hosting your servers, applications, servers, databases. Azure Container Instances (ACI) service offers to deploy your container instances in the Azure Infrastructure. These container instances start in a few seconds, and their billing is on a second basis. You can deploy these containers in the region as per your choice.
Azure Container Instance Features
- It supports both Linux and Windows OS-based containers
- You can deploy containers from the Azure portal, Azure CLI (command-line interface)
- It supports standard docker images, public registries, and Azure container registry
- You can access the Azure container over the internet with an IP address and a fully qualified domain name
- You can choose the required CPU cores and memory for the container instances
- It also supports persistent storage that helps drop and recreate the containers with the same storage without data loss
- You can deploy container groups that have identical storage, network resources
Deploy Azure Container instance using Azure Portal
Launch the Azure portal (https://portal.azure.com) and navigate to Container Instances in the services. If you have any existing container instances, you can view them here. Else, click on Create container instances.
In the Create Container Instances page, select the Azure subscription and create a new resource group. The resource group is like a logical container for all deployed Azure resources. For this article, let us create a resource group – azurecontainers, as shown below.
Scroll down on the basics page, and you find the container details section.
- Container name: It is the container name that you want to deploy. You can specify any globally unique name of your choice
- Region: Select the Azure region from the drop-down list
- Image source: In the image source, you get the following options:
- Quick start images
- Azure container registry
- Docker hub or another registry
For the Microsoft SQL Server, you can visit the URL to find out relevant image sources. For the latest SQL Server 2019, the URL is mcr.microsoft.com/mssql/server:2019-latest. In this article, we will use the image as mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04
Therefore, select the docker hub or another registry and paste the URL in the image box below.
- OS type: Select the operating system Windows or Linux. This selection of OS must match with the image type
- Size: You can specify the vCPU and GiB memory for the container instance size. Click on the changing size if you want a higher container configuration
SQL Server on Linux requires at least 2 GB memory. Therefore, click on change size and modify it as below.
You get the following error if you create a container instance with less than 2 GB memory.
On the next page, Networking, you get two options:
Networking type: You can choose networking types as Public, Private or None
- Public: Azure assigns a public IP address that you can access over the internet as well
- Private: The private allows you to choose a virtual network for the container instance. You cannot use it for Windows containers
- None: No public IP or virtual network will be assigned
- DNS name label: It is an optional feature, and you can assign a name for connecting to Container SQL with the FQDN instead of the IP address. Azure uses FQDN based on the specified region. For example, here, it has the domain name eastus2.azurecontainer.io
For this article, I choose the following configurations:
- Networking Type: Public
- DNS name label: myazurecontainersql
- Ports: Default TCP port for SQL Server as 1433
SQL Server on Linux requires few parameters for its installation. In the advanced tab, we need to assign those environment variables with their values.
- ACCEPT_EULA=Y: To accept the end-user license agreement
- MSSQL_SA_PASSWORD=****** ( SQL Server SA password)
Tags are optional name\value pairs that help to view bills for the deployed resources. Here, we specify the key-value pair Name as shown below.
On the next page, Azure performs the validation of user inputs. As shown below, my configuration status is – Validated passed.
Once you click on Create, it deploys the Azure container instance for SQL Server 2019.
Click on the go-to resource to view deployed container dashboard.
In the dashboard, note the following fields:
- Status: Running
- Public IP address: 220.127.116.11
- FQDN: myaurecontainersql.eastus.azurecontainer.io
- Tags: SQL Server Azure demo for container
- OS type: Linux
Connect to Azure Container instance for SQL Server 2019 using SSMS
You can connect to Azure container SQL Server using tools such as SSMS, Azure data studio. If you do not have SSMS already installed, use the following links to download and install them on your system.
- SQL Server Management Studio: The SSMS version 18.7 or later installs Azure Data Studio and SSMS in a single installable
- Azure Data Studio: You can install Azure data studio’s latest version separately from SSMS as well
Launch the SSMS and use the public IP address or FQDN with the SA password specified in the environment variables.
The following figure shows that you can connect to the Azure container instance for SQL Server 2019 using FQDN or Public IP addresses.
Execute the Select query @@version to check the SQL Server version. As shown below, its version – Microsoft SQL Server 2019 RTM-CU12 for my container.
Similarly, you can launch Azure Data Studio and use a public IP address, FQDN, to connect with SQL Server.
The ADS gives you few details such as version, computer name, edition, OS version in its dashboard.
Monitoring SQL Server container in Azure portal
The Azure container instances display compute resources insights using the Azure monitor. In the container dashboard, you get metrics for CPU, Memory, network byte received, Network byte transmitted.
You can customize monitoring details using the metrics section in the monitoring group. Here, you can select the metrics, time filter, chart type ( area chart, line chart, scatter chart, bar chart, and grid)
Similarly, you can configure Azure alerts for effectively monitoring Azure resources.
We will skip this alerts part for this article. You can browse existing Azure articles on SQLShack for learning about alerting.
Stop, Start and Restart Azure Container Instances
You can quickly stop, start or restart Azure container instances as per your requirement. In the container dashboard, You get options at the top for Start, Restart, Stop or Delete instances. Currently, the start button is greyed out because the container is already running.
Click on Stop and confirm to stop the container group.
It quickly stops the instances. You can note that once you stop the instance, it does not show the public IP address. However, it retains the FQDN we specified earlier.
Once the container is in stopped status, we can start it for connecting to SQL Server. Click on Start and confirm with Yes.
You get a new public IP address after restarting of Azure container. However, the FQDN remains the same. Therefore, if you plan to restart container instances, you should use FQDN instead of the public IP address.
In this article, we explore deploying SQL Server 2019 on Azure container instances using the Azure portal. The containers are a quick way to deploy SQL Server and provide greater flexibility, minimum start time. You can monitor the SQL on Azure containers using various metrics provided by Azure monitor.
Table of contents
|Deploying Azure Container Instances for SQL Server 2019|
|Create Azure Container Instances for SQL Server 2019 using Azure CLI|
|Store SQL Server files in Persistent Storage for Azure Container Instances|