Create an Azure SQL managed instance on Azure Arc

Prerequisites

Before you can proceed with the tasks in this article, you need to have the necessary tools. All deployments require the following tools:

  • Azure Data Studio

  • Azure Arc extension for Azure Data Studio

  • Azure CLI (az)

  • arcdata extension for Azure CLI

  • kubectl

    Additional client tools depending your environment. For a more comprehensive list, see Client tools.

In addition to the required tools, to complete the tasks, you need an Azure Arc data controller.

Create an Azure SQL Managed Instance

To view available options for create command for SQL Managed Instance, use the following command:

az sql mi-arc create --help

To create a SQL Managed Instance, use az sql mi-arc create. See the following examples for different connectivity modes:

Note

A ReadWriteMany (RWX) capable storage class needs to be specified for backups. Learn more about access modes If no storage class is specified for backups, the default storage class in Kubernetes is used and if this is not RWX capable, the Arc SQL Managed Instance installation may not succeed.

az sql mi-arc create -n <instanceName> --storage-class-backups <RWX capable storageclass>  --k8s-namespace <namespace> --use-k8s

Example:

az sql mi-arc create -n sqldemo --storage-class-backups mybackups --k8s-namespace my-namespace --use-k8s

Note

Names must be less than 60 characters in length and conform to DNS naming conventions.

When specifying memory allocation and vCore allocation use this formula to ensure your performance is acceptable: for each 1 vCore you should have at least 4GB of RAM of capacity available on the Kubernetes node where the SQL managed instance pod will run.

If you want to automate the creation of SQL instances and avoid the interactive prompt for the admin password, you can set the AZDATA_USERNAME and AZDATA_PASSWORD environment variables to the desired username and password prior to running the az sql mi-arc create command.

If you created the data controller using AZDATA_USERNAME and AZDATA_PASSWORD in the same terminal session, then the values for AZDATA_USERNAME and AZDATA_PASSWORD will be used to create the SQL managed instance too.

Note

If you are using the indirect connectivity mode, creating Azure SQL Managed Instance in Kubernetes will not automatically register the resources in Azure. Steps to register the resource are in the following articles:

View instance on Azure Arc

To view the instance, use the following command:

az sql mi-arc list --k8s-namespace <namespace> --use-k8s

You can copy the external IP and port number from here and connect to it using your favorite tool for connecting to a SQL Sever/Azure SQL instance such as Azure Data Studio or SQL Server Management Studio.

At this time, use the insiders build of Azure Data Studio.

Next steps