Need to create Azure SQL Managed Instance from existing VNET and SUBENT using ARM

Ravikumar P 21 Reputation points
2021-02-27T06:54:02.293+00:00

I need to create SQL Server Managed instance from existing VNET/SUBNET in ARM But I tried multiple ways but its didnt help and getting failed again and again So kindly help me to create script

Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. Ronen Ariely 15,091 Reputation points
    2021-02-27T11:04:53.07+00:00

    Good day Ravikumar < @Ravikumar P >

    Since we cannot see your screen or read mind, telling that you get error or that something failed without providing the exact error message is usually useless. Please try to provide the exact error message which you get (after removing any sensitive/personal information)

    In general not any vNet fits to be used for Menaged instance. Best option is to leab the vNet live when you delete a managed instance so you could always create another one using the same vNet. In this document you can get information about how to create a vNet which fit for Managed Instance. You can use the existing virtual network and subnet if they're configured according to the SQL Managed Instance virtual network requirements.

    In first glance I am guessing that your vNet does not fit the requirements.

    I recommend to start with a new vNet and follow the instructions in the links I added above.

    0 comments No comments

  2. Ravikumar P 21 Reputation points
    2021-02-28T07:03:41.377+00:00

    Hi Pituach

    Thanks for sharing information and We are going to deploy via ARM template for SQL MI.

    I need to create Resource in my existing VNET and SUBNET. find the error

    {
    "status": "Failed",
    "error": {
    "code": "InvalidTemplate",
    "message": "Unable to process template language expressions for resource '/subscriptions/e2a3dc4e-989d-47c5-af8b-2855a9ee07bf/resourceGroups/POC-RG-TECH/providers/Microsoft.Sql/managedInstances/test-sql-mi-01' at line '125' and column '9'. 'The template variable 'Vnetid' is not found. Please see https://aka.ms/arm-template/#variables for usage details.'",
    "additionalInfo": [
    {
    "type": "TemplateViolation",
    "info": {
    "lineNumber": 125,
    "linePosition": 9,
    "path": ""
    }
    }
    ]
    }
    }

    =================================================

    This is my code

    {
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.1",
    "parameters": {
    "managedInstanceName": {
    "type": "String",
    "metadata": {
    "description": "Enter managed instance name."
    }
    },
    "administratorLogin": {
    "type": "String",
    "metadata": {
    "description": "Enter user name."
    }
    },
    "administratorLoginPassword": {
    "type": "SecureString",
    "metadata": {
    "description": "Enter password."
    }
    },
    "location": {
    "defaultValue": "[resourceGroup().location]",
    "type": "String",
    "metadata": {
    "description": "Enter location. If you leave this field blank resource group location would be used."
    }
    },
    "VnetResourceGroup": {
    "type": "String",
    "metadata": {
    "description": "APG Vnet Resource group details to add IP restrictions to the webapp"
    }
    },
    "virtualNetworkName": {
    "defaultValue": "SQLMI-VNET",
    "type": "String",
    "metadata": {
    "description": "Enter virtual network name. If you leave this field blank name will be created by the template."
    }
    },
    "subnetName": {
    "defaultValue": "ManagedInstance",
    "type": "String",
    "metadata": {
    "description": "Enter subnet name."
    }
    },
    "skuName": {
    "defaultValue": "GP_Gen5",
    "allowedValues": [
    "GP_Gen5",
    "BC_Gen5"
    ],
    "type": "String",
    "metadata": {
    "description": "Enter sku name."
    }
    },
    "vCores": {
    "defaultValue": 16,
    "allowedValues": [
    8,
    16,
    24,
    32,
    40,
    64,
    80
    ],
    "type": "Int",
    "metadata": {
    "description": "Enter number of vCores."
    }
    },
    "storageSizeInGB": {
    "defaultValue": 256,
    "minValue": 32,
    "maxValue": 8192,
    "type": "Int",
    "metadata": {
    "description": "Enter storage size."
    }
    },
    "licenseType": {
    "defaultValue": "LicenseIncluded",
    "allowedValues": [
    "BasePrice",
    "LicenseIncluded"
    ],
    "type": "String",
    "metadata": {
    "description": "Enter license type."
    }
    }
    },
    "resources": [
    {
    "type": "Microsoft.Sql/managedInstances",
    "apiVersion": "2020-02-02-preview",
    "name": "[parameters('managedInstanceName')]",
    "location": "[parameters('location')]",
    "sku": {
    "name": "[parameters('skuName')]"
    },
    "identity": {
    "type": "SystemAssigned"
    },
    "properties": {
    "administratorLogin": "[parameters('administratorLogin')]",
    "administratorLoginPassword": "[parameters('administratorLoginPassword')]",
    "storageSizeInGB": "[parameters('storageSizeInGB')]",
    "vCores": "[parameters('vCores')]",
    "licenseType": "[parameters('licenseType')]",
    "virtualNetwork": {
    "id": "[resourceId(parameters('VnetResourceGroup'),'Microsoft.Network/virtualNetworks',parameters('VirtualNetworkName'),'/subnets/',parameters('subnetName'))]"

                }
            }
        }
    ]
    

    }

    Kindly help me on this

    0 comments No comments