Search code examples
sql-serverazureazure-container-serviceazure-container-instances

ACI sql server container does not point to file storage at startup


I am looking for making a sql server with a file storage persistence in Azure instance container(ACI) with a powershell script.

I do the following steps 1. Create ressource group 2. Create a file storage 3. Create a sql server container that use the file storage. 4. Retrieve all the log from the container

My problem is that the sql server in the container does not startup using the file/data location in the file storage.

I can see using docker the parameter -v or -mount is used, but i did not have succes with my attempts.

So any help will be appreciated

Thank you advance.

Mikael

Powershell script

param (

    # The ressource group name
    $ressourceGroup = "sql-container",

    # Location for where the instance is placed
    $location = "WestEurope",

    # Image name to download
    $imageName = "mcr.microsoft.com/mssql/server:latest-ubuntu",    

    # Dns name for this instanse
    $dnsName = "sql-test99",

    # Database instanse name
    $databaseInstanseName = "mssql-2019",

    # Database collatino type
    $databaseCollation = "Danish_Norwegian_CI_AS",

    # Database login name
    $databaseLoginName = "SA",

    # Database login name
    $databaseLoginPassword = "!thisWillMakeMyDayEveryDayIn2019",

    # Database default locations
    $databaseDefaultLocation = "/mnt/mydata/",

    # SQL server name
    $sqlServerFullName = $dnsName + "." + $location + ".azurecontainer.io",

    # Storage account name  
    $storage_account_name = "mikaelsqlstorageaccount",

    # Storage share name    
    $storage_share_name = "sqlsharestorage",

    # Storage key
    $storage_key
)

az group create --name $ressourceGroup --location $location

az Storage account create --resource-group $ressourceGroup --name $storage_account_name --location $location --sku Standard_LRS

az Storage share create --name $storage_share_name --account-name $storage_account_name

$script:storage_key=$(az Storage account keys list --resource-group $ressourceGroup --account-name $storage_account_name --query "[0].value" --output tsv)

az container create --image $imageName --name $databaseInstanseName --resource-group $ressourceGroup --cpu 1 --memory 3.5 --port 1433 --ip-address public -e ACCEPT_EULA=Y MSSQL_SA_PASSWORD=$databaseLoginPassword MSSQL_PID=Developer MSSQL_COLLATION=$databaseCollation MSSQL_ENABLE_HADR=Y MSSQL_BACKUP_DIR=$databaseDefaultLocation MSSQL_DATA_DIR=$databaseDefaultLocation MSSQL_LOG_DIR=$databaseDefaultLocation MSSQL_DUMP_DIR=$databaseDefaultLocation --location $location --dns-name-label $dnsName --azure-file-volume-account-name $storage_account_name --azure-file-volume-account-key $storage_key --azure-file-volume-share-name $storage_share_name --azure-file-volume-mount-path $databaseDefaultLocation

az container logs --resource-group $ressourceGroup --name $databaseInstanseName

SQL Container log

2019-10-07 08:41:08.07 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2019-10-07 08:41:08.07 Server      Registry startup parameters: 
     -d /var/opt/mssql/data/master.mdf
     -l /var/opt/mssql/data/mastlog.ldf
     -e /var/opt/mssql/log/errorlog
.
.
2019-10-07 08:41:19.84 spid16s      index restored for master.syspriorities.
2019-10-07 08:41:20.45 spid30s     ***Stack Dump being sent to /mnt/mydata/SQLDump0001.txt

2019-10-07 08:41:20.49 spid30s     SqlDumpExceptionHandler: Process 30 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

Solution

  • According to the message that you provided, the possible reason is that the mount path should be /mnt/mydata/. So you need to change the variable databaseDefaultLocation with the right path format. And you can also see the example here.

    By the way, the persistent volumes do not support the Windows container in ACI. So you also need to pay attention to it. For more details, see the Note here.