Rajendra Gupta
Monitoring network bytes

Deploying Azure Container Instances for SQL Server 2019

December 3, 2021 by

This article will show how to deploy SQL Server 2019 on the Azure container instances using the Azure portal.

Introduction

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.

Container apps

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.

Azure Container Instance Features

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.

Create Container instace

Scroll down on the basics page, and you find the container details section.

Enter information Container name, region

  • 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

Specify the image for container

SQL Server on Linux requires at least 2 GB memory. Therefore, click on change size and modify it as below.

Specify vCPU and Memory

You get the following error if you create a container instance with less than 2 GB memory.

Check container logs

Networking

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

Networking config

Advanced

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)

Environment variables

Tags

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.

Tag

On the next page, Azure performs the validation of user inputs. As shown below, my configuration status is – Validated passed.

Review and deploy containers

Once you click on Create, it deploys the Azure container instance for SQL Server 2019.

Deployment status

Click on the go-to resource to view deployed container dashboard.

View resources

In the dashboard, note the following fields:

  • Status: Running
  • Public IP address: 52.146.63.60
  • FQDN: myaurecontainersql.eastus.azurecontainer.io
  • Tags: SQL Server Azure demo for container
  • OS type: Linux

Note-down IP address and FQDN

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.

Launch the SSMS and use the public IP address or FQDN with the SA password specified in the environment variables.

Connect SQL Server using IP

The following figure shows that you can connect to the Azure container instance for SQL Server 2019 using FQDN or Public IP addresses.

Connect SQL Server using FQDN

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.

Verify SQL Server version

Similarly, you can launch Azure Data Studio and use a public IP address, FQDN, to connect with SQL Server.

Connection details

The ADS gives you few details such as version, computer name, edition, OS version in its dashboard.

View Azure Data Studio 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.

Monitoring metrics

Monitoring network bytes

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)

Customized metrics

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.

Azure alerts

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.

container instance stop, restart options

Stop container instance

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.

Verify stopped container

Once the container is in stopped status, we can start it for connecting to SQL Server. Click on Start and confirm with Yes.

Start container

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.

Verify started container

Conclusion

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
Rajendra Gupta
2,387 Views