Deploying SQL Server on Azure Container Instances
  • 22 Sep 2022
  • 1 Minute to read
  • Dark
  • PDF

Deploying SQL Server on Azure Container Instances

  • Dark
  • PDF

#ServerlessTips - Azure Container Instances
Author: Rahul Rai Azure MVP

Azure Container Instances support mounting Azure file shares for storing the state of the container beyond its lifetime. This article will attach Azure file share to our container instance running SQL Server.

Use the following Azure CLI commands to create a storage account and a file share. Replace the name of the resource group, storage account name, location, and file share name, with custom values:

# Create a storage account
az storage account create \
    --resource-group serverlessnotes-rg \
    --name serverlessnotesstorage \
    --location eastus \
    --sku Standard_LRS

# Create the file share
az storage share create \
  --name acishare \
  --account-name serverlessnotesstorage

Copy the storage account key using the following command:

az storage account keys list --resource-group serverlessnotes-rg --account-name serverlessnotesstorage --query "[0].value" --output tsv

Execute the following command to create a SQL Server container that uses the file share for storing the data. Remember to replace the parameter values below with your own:

az container create  \ 
--resource-group serverlessnotes-rg  \
--name mysqlserverlinuxcontainer  \
--image  \
--environment-variables ACCEPT_EULA=Y MSSQL_SA_PASSWORD=<password> `
--ip-address public  \
--cpu 2  \
--memory 2  \
--port 1433   \
--azure-file-volume-account-name serverlessnotesstorage  \
--azure-file-volume-account-key <storage account key> \
--azure-file-volume-share-name acishare \
--azure-file-volume-mount-path "/var/opt/mssql"

Following is a screenshot of the command output:


You can find the public IP address of the container using the Azure management portal or the docker ps command as follows:


Use SQL Server Management Studio (SSMS) or VS Code to log in to the remote SQL server using the IP address as the server name and the credentials that you configured.

The following screenshot shows the operation to create a database on the server with VSCode:


You can use the Azure management portal to view the contents of the file share that includes the database that you created.


Was this article helpful?