SOLVED

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

Copper Contributor

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 virutalnetworkrules, I'm getting the following error:

 

  • RESOURCE ID
    /subscriptions/guid/resourceGroups/RG-SQLtest/providers/Microsoft.Sql/servers/testsqlserver001/virtualNetworkRules/AllowVnet
  • STATUSMESSAGE
    { "error": { "code": "InternalServerError", "message": "An unexpected error occured while processing the request. Tracking ID: 'ed836246-e40b-41ee-a88a-893e606f2070'" } }
  • RESOURCE
    testsqlserver001/AllowVnet
     
    Azure SQL template:
     
    "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": "firewallrules",
    "location": "[resourceGroup().location]",
    "apiVersion": "2014-04-01-preview",
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', variables('AzureSqlServerName'))]"
    ],
    "properties": {
    "startIpAddress": "0.0.0.0",
    "endIpAddress": "0.0.0.0"
    }
    },
    {
    "name": "AllowVnet",
    "type": "virtualNetworkRules",
    "apiVersion": "2015-05-01-preview",
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', variables('AzureSqlServerName'))]"
    ],
    "properties": {
    "virtualNetworkSubnetId": "[variables('VMSqlVnetID')]"
    }
    },
    {
    "name": "[variables('FWRuleName')]",
    "type": "firewallrules",
    "location": "[resourceGroup().location]",
    "apiVersion": "2014-04-01-preview",
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', variables('AzureSqlServerName'))]"
    ],
    "properties": {
    "startIpAddress": "[variables('FWRuleIP')]",
    "endIpAddress": "[variables('FWRuleIP')]"
    }
    }
    ]

 

1 Reply
best response confirmed by Mohamed Shehata (Copper Contributor)
Solution

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
1 best response

Accepted Solutions
best response confirmed by Mohamed Shehata (Copper Contributor)
Solution

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

View solution in original post