Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure API enables you to create Azure SQL Managed Instance using ARM templates. These are JSON objects that contain definition of resources that should be created. You can send these objects to the Azure REST API to automate creation of Azure SQL Managed Instance.
Azure enables you describe resources that you need using ARM templates and specify in the code what kind of resources you need and what infrastructure you want to build (so called infrastructure as a code concept). If you are not familiar with ARM templates, it might be good to read how to create ARM template.
In order to create a new Azure SQL Managed Instance using ARM templates, you need to create ARM JSON request. An example of ARM JSON request is shown in the following script (the important part is under resources node):
{
"$schema": "https://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
"pwd": {
"type": "securestring"
}
},
"resources": [
{
"name": "jovanpoptest",
"location": "westcentralus",
"tags": {"Owner":"JovanPop","Purpose":"Test"},
"sku": {
"name": "GP_Gen4"
},
"properties": {
"administratorLogin": "Login that will connect to the instance",
"administratorLoginPassword": "[parameters('pwd')]",
"subnetId": "/subscriptions/ee5ea899-0791-9270-77cd8273794b/resourceGroups/cl_pilot/providers/Microsoft.Network/virtualNetworks/cl_pilot/subnets/CLean",
"storageSizeInGB": 256,
"vCores": 16,
"licenseType": "BasePrice"
},
"type": "Microsoft.Sql/managedInstances",
"identity": {
"type": "SystemAssigned"
},
"apiVersion": "2015-05-01-preview"
}
]
}
Values that you need to change in this request are:
Note that you cannot enter password as plain text - you need to specify parameters as a securestring, and pass it via PowerShell.
Once you create this JSON template you should save it to your local computer in some file (for example c:\\temp\newmi.json) and use this file as an input for PowerShell command that will execute it.
In order to execute ARM template, you would need to install Azure RM PowerShell. In most of the cases the following three commands might install everything that you need:
Install-Module PowerShellGet -Force
Install-Module -Name AzureRM -AllowClobber
Install-Module -Name AzureRM.Sql -AllowPrerelease -Force
you would need at east 1.6.0 version of PowerShellGet. In some cases this version would not be loaded, so you would need to run something like:
Import-PackageProvider -Name PowerShellGet -Force -RequiredVersion 1.6.0
Then, you need to run something like to following PowerShell script:
Connect-AzureRmAccount
Select-AzureRmSubscription -Subscription "<put-your-subscription-id-here>"
$secpasswd = ConvertTo-SecureString "<put-strong-password>" -AsPlainText -Force
New-AzureRmResourceGroupDeployment -pwd $secpasswd -ResourceGroupName my_rg -TemplateFile 'c:\temp\newmi.json'
This script will first connect to your Azure account with Connect-AzureRmAccount where you will need to enter your Azure credential, select subscription where you want to put Managed Instance, create secure password, and execute New-AzureRmResourceGroupDeployment that will send ARM request to Azure API. -pwd parameter must match the name of the parameter in JSON ARM object and must be defined as secure string:
"parameters": {
"pwd": { "type": "securestring" }
}
In this command you need to specify some resource group (my_rg in this example), and provide password and path to ARM JSON request file (c:\\temp\newmi.json in this case).
If there are no errors in your script, you will create new Managed Instance.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in