Skip to content

Commit

Permalink
Tweak Azure networking config to prevent duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisameling committed Dec 20, 2022
1 parent 5e04638 commit 601e9d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 29 deletions.
9 changes: 0 additions & 9 deletions azure-arm-template-example-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
"location": {
"value": "westeurope"
},
"networkInterfaceName1": {
"value": "test-vm862_z1"
},
"enableAcceleratedNetworking": {
"value": true
},
"networkSecurityGroupName": {
"value": "test-vm-nsg"
},
"networkSecurityGroupRules": {
"value": [
{
Expand All @@ -34,9 +28,6 @@
"subnetName": {
"value": "default"
},
"virtualNetworkName": {
"value": "test-vm_group-vnet"
},
"addressPrefixes": {
"value": [
"10.2.0.0/16"
Expand Down
32 changes: 12 additions & 20 deletions azure-arm-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,15 @@
"location": {
"type": "string"
},
"networkInterfaceName1": {
"type": "string"
},
"enableAcceleratedNetworking": {
"type": "bool"
},
"networkSecurityGroupName": {
"type": "string"
},
"networkSecurityGroupRules": {
"type": "array"
},
"subnetName": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"addressPrefixes": {
"type": "array"
},
Expand Down Expand Up @@ -101,20 +92,21 @@
}
},
"variables": {
"nsgId": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]",
"vnetName": "[parameters('virtualNetworkName')]",
"vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"nsgName": "[concat(parameters('virtualMachineName'), '-nsg')]",
"nicName": "[concat(parameters('virtualMachineName'), '-nic')]",
"vnetName": "[concat(parameters('virtualMachineName'), '-vnet')]",
"vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', concat(parameters('virtualMachineName'), '-vnet'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
},
"resources": [
{
"name": "[parameters('networkInterfaceName1')]",
"name": "[variables('nicName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2021-03-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]",
"[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName1'))]"
],
"properties": {
Expand All @@ -137,12 +129,12 @@
],
"enableAcceleratedNetworking": "[parameters('enableAcceleratedNetworking')]",
"networkSecurityGroup": {
"id": "[variables('nsgId')]"
"id": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
}
}
},
{
"name": "[parameters('networkSecurityGroupName')]",
"name": "[variables('nsgName')]",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-02-01",
"location": "[parameters('location')]",
Expand All @@ -151,7 +143,7 @@
}
},
{
"name": "[parameters('virtualNetworkName')]",
"name": "[variables('vnetName')]",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"location": "[parameters('location')]",
Expand Down Expand Up @@ -183,7 +175,7 @@
"apiVersion": "2021-07-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName1'))]"
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
Expand All @@ -207,7 +199,7 @@
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName1'))]",
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName))]",
"properties": {
"deleteOption": "[parameters('nicDeleteOption')]"
}
Expand Down

0 comments on commit 601e9d3

Please sign in to comment.