-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Lets say for example: we have azure ARM mariadb resource at https://github.com/prancer-io/prancer-armof/blob/master/mariadb/azuredeploy.json
it has a firewallrules object type variable with 2 child rules defined in the template which contains StartIpAddress and EndIpAddress property value:
"variables": {
"firewallrules": {
"batch": {
"rules": [
{
"Name": "rule1",
"StartIpAddress": "0.0.0.0",
"EndIpAddress": "255.255.255.255"
},
{
"Name": "rule2",
"StartIpAddress": "0.0.0.0",
"EndIpAddress": "255.255.255.255"
}
]
}
}
}
During snapshot file creation we assume value from these StartIpAddress and EndIpAddress get replaced on below resource's startIpAddress and endIpAddress property but it is not getting the value from variable during snapshot file creation:
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[parameters('location')]",
"copy": {
"name": "firewallRulesCopy",
"mode": "Serial",
"batchSize": 1,
"count": "[length(variables('firewallrules').batch.rules)]"
},
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "[variables('firewallrules').batch.rules[copyIndex()].StartIpAddress]",
"endIpAddress": "[variables('firewallrules').batch.rules[copyIndex()].EndIpAddress]"
}
}
Note: there is a copy object in this resource with count value coming from number of rules in the firewallrules variable, so this resource should have a 2 cloned copy based on 2 different firewall rules as well but i am seeing tons of cloned copy in the resource snapshot which is not expected also the value is not present.
here is the resource snapshot created with prancer basic version 2.0.3:
{
"structure": "filesystem",
"error": null,
"reference": "master",
"contentType": "json",
"source": "gitConnectorArm",
"paths": [
"/mariadb/azuredeploy.json",
"/mariadb/azuredeploy.parameters.json"
],
"timestamp": 1635311633688,
"queryuser": null,
"checksum": "99914b932bd37a50b983c5e7c90ae93b",
"node": {
"masterSnapshotId": "ARM_TEMPLATE_SNAPSHOT",
"type": "arm",
"collection": "armtemplate",
"paths": [
"/mariadb/azuredeploy.json",
"/mariadb/azuredeploy.parameters.json"
],
"snapshotId": "ARM_TEMPLATE_SNAPSHOT4",
"status": "active",
"validate": true,
"resourceTypes": [
"microsoft.dbformariadb/servers/firewallrules",
"microsoft.network/virtualnetworks",
"microsoft.dbformariadb/servers"
]
},
"snapshotId": "ARM_TEMPLATE_SNAPSHOT4",
"collection": "armtemplate",
"json": {
"contentVersion": "1.0.0.0",
"parameters": {
"serverName": {
"type": "string",
"metadata": {
"description": "Server Name for Azure database for MariaDB"
},
"value": "GEN-UNIQUE"
},
"administratorLogin": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Database administrator login name"
},
"value": "GEN-UNIQUE-8"
},
"administratorLoginPassword": {
"type": "securestring",
"minLength": 8,
"metadata": {
"description": "Database administrator password"
},
"value": "GEN-PASSWORD"
},
"skuCapacity": {
"type": "int",
"defaultValue": 2,
"metadata": {
"description": "Azure database for MariaDB compute capacity in vCores (2,4,8,16,32)"
}
},
"skuName": {
"type": "string",
"defaultValue": "GP_Gen5_2",
"metadata": {
"description": "Azure database for MariaDB sku name "
}
},
"skuSizeMB": {
"type": "int",
"defaultValue": 51200,
"metadata": {
"description": "Azure database for MariaDB Sku Size "
}
},
"skuTier": {
"type": "string",
"defaultValue": "GeneralPurpose",
"metadata": {
"description": "Azure database for MariaDB pricing tier"
}
},
"skuFamily": {
"type": "string",
"defaultValue": "Gen5",
"metadata": {
"description": "Azure database for MariaDB sku family"
}
},
"mariadbVersion": {
"type": "string",
"defaultValue": "10.3",
"allowedValues": [
"10.2",
"10.3"
],
"metadata": {
"description": "MariaDB version"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"backupRetentionDays": {
"type": "int",
"defaultValue": 7,
"metadata": {
"description": "MariaDB Server backup retention days"
}
},
"geoRedundantBackup": {
"type": "string",
"defaultValue": "Disabled",
"metadata": {
"description": "Geo-Redundant Backup setting"
}
},
"virtualNetworkName": {
"type": "string",
"defaultValue": "azure_mariadb_vnet",
"metadata": {
"description": "Virtual Network Name"
}
},
"subnetName": {
"type": "string",
"defaultValue": "azure_mariadb_subnet",
"metadata": {
"description": "Subnet Name"
}
},
"virtualNetworkRuleName": {
"type": "string",
"defaultValue": "AllowSubnet",
"metadata": {
"description": "Virtual Network RuleName"
}
},
"vnetAddressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Virtual Network Address Prefix"
}
},
"subnetPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Subnet Address Prefix"
}
}
},
"variables": {
"firewallrules": {
"batch": {
"rules": [
{
"Name": "rule1",
"StartIpAddress": "0.0.0.0",
"EndIpAddress": "255.255.255.255"
},
{
"Name": "rule2",
"StartIpAddress": "0.0.0.0",
"EndIpAddress": "255.255.255.255"
}
]
}
}
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-06-01",
"name": "azure_mariadb_vnet",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
}
},
"resources": [
{
"type": "subnets",
"apiVersion": "2020-06-01",
"name": "azure_mariadb_subnet",
"location": "[resourceGroup().location]",
"dependsOn": [
"azure_mariadb_vnet"
],
"properties": {
"addressPrefix": "10.0.0.0/16"
}
}
]
},
{
"type": "Microsoft.DBforMariaDB/servers",
"apiVersion": "2018-06-01",
"name": "GEN-UNIQUE",
"location": "[resourceGroup().location]",
"sku": {
"name": "GP_Gen5_2",
"tier": "GeneralPurpose",
"capacity": 2,
"size": 51200,
"family": "Gen5"
},
"properties": {
"createMode": "Default",
"version": "10.3",
"administratorLogin": "GEN-UNIQUE-8",
"administratorLoginPassword": "GEN-PASSWORD",
"storageProfile": {
"storageMB": 51200,
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled"
}
},
"resources": [
{
"type": "virtualNetworkRules",
"apiVersion": "2018-06-01",
"name": "AllowSubnet",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"virtualNetworkSubnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('subnetName'))]",
"ignoreMissingVnetServiceEndpoint": true
}
},
{
"type": "firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[0].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[0].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[0].EndIpAddress"
}
}
]
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
},
{
"type": "Microsoft.DBforMariaDB/servers/firewallRules",
"apiVersion": "2018-06-01",
"name": "[concat(parameters('serverName'),'/',variables('firewallrules').batch.rules[copyIndex()].Name)]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.DBforMariaDB/servers/', parameters('serverName'))]"
],
"properties": {
"startIpAddress": "(firewallrules).batch.rules[copyIndex()].StartIpAddress",
"endIpAddress": "(firewallrules).batch.rules[copyIndex()].EndIpAddress"
}
}
],
"\uff04schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"
},
"resourceTypes": [
"microsoft.dbformariadb/servers/firewallrules",
"microsoft.network/virtualnetworks",
"microsoft.dbformariadb/servers"
]
}