In this blog we will learn about Azure container services and how to deploy SQL server 2019 on Azure Container Services?
Hardware virtualization has made it possible to run multiple isolated instances of operating systems simultaneously on the same physical hardware. Containers is the next stage in the virtualization of computing resources. Container-based virtualization allows us to virtualize the operating system. This way, we can run multiple applications within the same instance of an operating system, while maintaining isolation between the applications. Containers within a VM provide functionality similar to that of VMs within a physical server.
Containers vs Virtual Machines
|Isolation||-Lightweight isolation from the host and other containers |
-Weak security boundary as compared to the virtual machine.
|– Complete isolation from the host operating |
-Strong security boundary
|Operating system||User mode portion of an operating system but it can be tailoreed to contain just the needed services with a fewer system footprint.||Runs a complete OS including and more system resources (CPU, memory, and storage).|
|Deployment||-Deploy single containers by using command line or |
-Deploy multiple containers by using an orchestrator like Azure Kubernetes Service.
|Deploy individual VMs by using |
-Windows Admin Center or
Deploy multiple VMs by using
-System Center Virtual Machine Manager.
|Persistent storage||-Azure Disks can be attached as a local storage for a single node container, |
-Azure Files (SMB shares) can be attachedto multiple container nodes .
|-Virtual hard disk (VHD) for local storage for a single VM, or |
-SMB file share for storage shared by multiple servers.
|Fault tolerance||If a cluster node fails, any containers running on it are rapidly recreated by the Orchestrator (Kubernetes) on another cluster node.||VMs can fail over to another server in a failover cluster configuration.|
Azure container services has some great features:
|Fast Startup Times||Containers can start in seconds without manually provisioning and managing virtual machines.|
|Public IP Connectivity and DNS Names||Containers can be directly exposed and accessed from the internet with an IP address and a FQDN.|
|Hypervisor-level Security||Container applications are as isolated in a container as they would be in a virtual machine.|
|Custom Sizes||Container nodes can be scaled dynamically to match actual resource demands for an application workload.|
|Persistent Storage||Containers supports direct mounting of Azure File Shares.|
|Linux and Windows Containers||You can choose Linux based container or Windows based containers.|
|Co-scheduled Groups||Container instances supports scheduling of multi-container groups that share host machine resources.|
|Virtual Network Deployment||Container instances can be deployed into an Azure virtual network.|
Container group is a Top-level resource in Azure Container Instances. It is a collection of containers that get scheduled on the same host and shares a lifecycle, resources, local network, and storage volumes.
Contain group example shows that two containers are depoyed into single host machine.Is scheduled on a single host machine.Is assigned a DNS name label and exposesed a single public IP address, with one exposed port.It consists of two containers. One container listens on port 80, while the other listens on port 1433.It also includes two Azure file shares as volume mounts, and each container mounts one of the shares locally.
Dockers enables developers to host applications within a container. A container is a standardized “unit of software” that contains everything required for an application to run It is available on both Linux and Windows and can be hosted on Azure
Here is the important Docker Terminology:
Container. This is an instance of a Docker image. It represents the execution of a single application, process, or service. It consists of the contents of a Docker image, an execution environment, and a standard set of instructions. While scaling a service/Application, you create multiple instances of a container from the same image. Or a batch job can create multiple containers from the same image, passing different parameters to each instance.
Container image. Container image is a package with all the dependencies and information required to create a container. The dependencies include frameworks and the deployment and execution configuration that a container runtime uses. Usually, an image derives from multiple base images that are layers stacked on top of each other to form the container’s file system. An image is immutable once it has been created.
Build. Action of building a container image based on the information and context provided by its Dockerfile, plus additional files in the folder where the image is built. You can build images by using the Docker docker build command.
Pull. The process of downloading a container image from a container registry.
Push. The process of uploading a container image to a container registry.
Dockerfile. A text file that contains instructions on how to build a Docker image.
Deploying SQL server 2019 on Azure Container Services.
Here are the step by step instructions to execute instructions on Azure Container Services.
1.Login to Azure Portal and create ContainerRG Resource Group.
az login az group create --name containerRG --location eastUS
2.Create Azure container instance providing these parameters:
- Resource group,
- CPU (1 Core),
- memory (3.5 = 3.5 GB),
- Port 1433 for SQL server,
- DNS name so it can be accessed from internet
- Environment variables ACCEPT_EULA=Y MSSQL_SA_PASSWORD=Password@001 MSSQL_PID=Developer MSSQL_COLLATION=Latin1_General_CI_AS MSSQL_ENABLE_HADR=Y
az container create --image mcr.microsoft.com/mssql/server:2019-latest --name sql-2019 --resource-group containerRG --cpu 1 --memory 3.5 --port 1433 --ip-address public -e ACCEPT_EULA=Y MSSQL_SA_PASSWORD=Password@001 MSSQL_PID=Developer MSSQL_COLLATION=Latin1_General_CI_AS MSSQL_ENABLE_HADR=Y --location eastus --dns-name-label sqlserverdemo
3.Access Container logs coming from SQL server.
az container logs --resource-group containerRG --name sql-2019
4.Now test the connectvity from SQL server Management studio if you are able to connect to the container or not? use the username sa and password you used while setting upo the container.
5. Now install SQLCMD and open command prompt and run this command to find if you are able to run the SQL commands on the SQL instance deployed on Azure container services. Use the IP address from the azure portal and password used while creating the SQL server 2019 instance.You will see that command executes successfully.
sqlcmd -S 220.127.116.11 -U SA -P Password@001 -Q "select @@version"
Hope you liked this post.