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?

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.