1

I need to automate creation of Azure SQL Database Managed Instance using PowerShell scripts (AzureRm.Sql). What command should be used to create it?

Jovan MSFT
  • 13,232
  • 4
  • 40
  • 55

1 Answers1

1

If you have installed AzureRm.Sql and properly configured network environment (VNet and subnet), you can use the following script that deploys 8-core "General Purpose" instance with 1024 max storage:

Select-AzureRmSubscription -Subscription "60d9f1df-......"

$resourceGroup = "<resource group>"
$vNetName = "<VNet name"
$subnetName = "<subnet name>"
$instanceName = "<subnet name>"
$region = "South India"

$vNet = Get-AzureRmVirtualNetwork -Name $vNetName -ResourceGroupName $resourceGroup
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -VirtualNetwork $vNet
$subnetId = $subnet.Id


New-AzureRmSqlManagedInstance -Name $instanceName `
-ResourceGroupName $resourceGroup -Location $region -SubnetId $subnetId `
-AdministratorCredential (Get-Credential) `
-StorageSizeInGB 1024 -VCore 8 -Edition "GeneralPurpose" `
-ComputeGeneration Gen5 -LicenseType BasePrice
Jovan MSFT
  • 13,232
  • 4
  • 40
  • 55
  • Is it possible to use the New-AzureRmSqlManagedInstance command to create a secondary failover SQL MI instance? The documentation on this aspect appears to be non-existent. For example, no documentation on how to use the DNSZonePartner parameter which is required to setup a failover group. – Traiano Welcome Nov 01 '19 at 04:34