Forum Discussion

Mohamed Shehata's avatar
Mohamed Shehata
Copper Contributor
Jul 27, 2018
Solved

Error when trying to set Allow virtual network in ARM template (Azure SQL server)

I'm using an ARM template to provision an Azure SQL server with elastic pool and setting:   virtualNetworkRules firewallrules.   The whole template is working without any issues, except for viru...
  • carlosdoliveira's avatar
    Jul 30, 2018

    Hey, Mohamed, hope you're doing fine.

    Checking JSON reference about elastic pools and firewall rules,  at line 17, when you specify the "type", is not just "firewallrules", instead you must use this one: "Microsoft.Sql/servers/firewallRules".

    At line 29, the same applies to Virtual Network Rules which is: "Microsoft.Sql/servers/virtualNetworkRules". Then, our whole template would be like this:
    "resources": [
    {
    "name": "[variables('AzureSqlServerName')]",
    "type": "Microsoft.Sql/servers",
    "location": "[resourceGroup().location]",
    "apiVersion": "2015-05-01-preview",
    "dependsOn": [],
    "properties": {
    "administratorLogin": "[parameters('sqlserverAdminLogin')]",
    "administratorLoginPassword": "[parameters('sqlserverAdminLoginPassword')]"
    },
    "resources": [
    {
    name": "AllowAllWindowsAzureIps",
    "type": "Microsoft.Sql/servers/firewallRules",
    "location": "[resourceGroup().location]"
    "apiVersion": "2015-05-01-preview",
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', variables('AzureSqlServerName'))]"
    ],
    "properties": {
    "startIpAddress": "0.0.0.0",
    "endIpAddress": "0.0.0.0"
    }
    },
    {
    "name": "AllowVnet",
    "type": "Microsoft.Sql/servers/virtualNetworkRules",
    "apiVersion": "2015-05-01-preview",
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', variables('AzureSqlServerName'))]"
    ],
    "properties": {
    "virtualNetworkSubnetId": "[variables('VMSqlVnetID')]"
    }
    },
    {
    "name": "[variables('FWRuleName')]",
    "type": "Microsoft.Sql/servers/firewallRules",
    "location": "[resourceGroup().location]",
    "apiVersion": "2015-05-01-preview",
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', variables('AzureSqlServerName'))]"
    ],
    "properties": {
    "startIpAddress": "[variables('FWRuleIP')]",
    "endIpAddress": "[variables('FWRuleIP')]"
    }
    }
    ]
    Please, try this adjustments and let us know if it worked.
    Best Regards,
    Carlos