diff --git a/azure-arm-template-example-parameters.json b/azure-arm-template-example-parameters.json index 4bfab42..627d90a 100644 --- a/azure-arm-template-example-parameters.json +++ b/azure-arm-template-example-parameters.json @@ -5,15 +5,9 @@ "location": { "value": "westeurope" }, - "networkInterfaceName1": { - "value": "test-vm862_z1" - }, "enableAcceleratedNetworking": { "value": true }, - "networkSecurityGroupName": { - "value": "test-vm-nsg" - }, "networkSecurityGroupRules": { "value": [ { @@ -34,9 +28,6 @@ "subnetName": { "value": "default" }, - "virtualNetworkName": { - "value": "test-vm_group-vnet" - }, "addressPrefixes": { "value": [ "10.2.0.0/16" diff --git a/azure-arm-template.json b/azure-arm-template.json index 12e0269..25a1d50 100644 --- a/azure-arm-template.json +++ b/azure-arm-template.json @@ -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" }, @@ -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": { @@ -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')]", @@ -151,7 +143,7 @@ } }, { - "name": "[parameters('virtualNetworkName')]", + "name": "[variables('vnetName')]", "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2020-11-01", "location": "[parameters('location')]", @@ -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": { @@ -207,7 +199,7 @@ "networkProfile": { "networkInterfaces": [ { - "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName1'))]", + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName))]", "properties": { "deleteOption": "[parameters('nicDeleteOption')]" }