Azure PowerShell samples for Azure SQL Managed Instance

Applies to: Azure SQL Managed Instance

Azure SQL Managed Instance enables you to configure your instances, and pools by using Azure PowerShell.

If you don't have an Azure trail subscription, create a trial subscription before you begin.

This tutorial requires AZ PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount -Environment AzureChinaCloud to create a connection with Azure.

Samples

The following table includes links to sample Azure PowerShell scripts for Azure SQL Managed Instance.

Link Description
Create and configure managed instances
Create and manage a managed instance This PowerShell script shows you how to create and manage a managed instance using Azure PowerShell.
Create and manage a managed instance using the Azure Resource Manager template This PowerShell script shows you how to create and manage a managed instance using Azure PowerShell and the Azure Resource Manager template.
Restore database to a managed instance in another geo-region This PowerShell script takes a backup of one database and restores it to another region. This is known as a geo-restore disaster-recovery scenario.
Configure transparent data encryption
Manage transparent data encryption in a managed instance using your own key from Azure Key Vault This PowerShell script configures transparent data encryption in a Bring Your Own Key scenario for Azure SQL Managed Instance, using a key from Azure Key Vault.
Configure a failover group
Configure a failover group for a managed instance This PowerShell script creates two managed instances, adds them to a failover group, and then tests failover from the primary managed instance to the secondary managed instance.

Learn more about PowerShell cmdlets for Azure SQL Managed Instance.

The examples listed on this page use az.sql PowerShell cmdlets for creating and managing Azure SQL resources. Additional cmdlets for running queries and performing many database tasks are located in the SqlServer PowerShell cmdlets. For more information, see SQL Server PowerShell.