-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbdc4a3
commit afd7418
Showing
1 changed file
with
162 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,179 +1,180 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"vmName": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Name of the VM" | ||
} | ||
}, | ||
"location": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Location for the resources" | ||
} | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"vmName": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Name of the VM" | ||
} | ||
}, | ||
"location": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Location for the resources" | ||
} | ||
}, | ||
"sshPublicKey": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "SSH public key for authentication" | ||
} | ||
} | ||
}, | ||
"variables": { | ||
"nsgName": "[concat(parameters('vmName'), '-nsg')]", | ||
"pipName": "[concat(parameters('vmName'), '-ip')]" | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Network/publicIPAddresses", | ||
"apiVersion": "2021-02-01", | ||
"name": "[variables('pipName')]", | ||
"location": "[parameters('location')]", | ||
"sku": { | ||
"name": "Standard" | ||
}, | ||
"properties": { | ||
"publicIPAllocationMethod": "Static" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Network/virtualNetworks", | ||
"apiVersion": "2021-02-01", | ||
"name": "[concat(parameters('vmName'), '-vnet')]", | ||
"location": "[parameters('location')]", | ||
"properties": { | ||
"addressSpace": { | ||
"addressPrefixes": ["10.0.0.0/16"] | ||
}, | ||
"sshPublicKey": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "SSH public key for authentication" | ||
"subnets": [ | ||
{ | ||
"name": "default", | ||
"properties": { | ||
"addressPrefix": "10.0.0.0/24" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"variables": { | ||
"nsgName": "[concat(parameters('vmName'), '-nsg')]" | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Network/publicIPAddresses", | ||
"apiVersion": "2021-02-01", | ||
"name": "[concat(parameters('vmName'), '-ip')]", | ||
"location": "[parameters('location')]", | ||
"sku": { | ||
"name": "Basic" | ||
}, | ||
{ | ||
"type": "Microsoft.Network/networkSecurityGroups", | ||
"apiVersion": "2021-02-01", | ||
"name": "[variables('nsgName')]", | ||
"location": "[parameters('location')]", | ||
"properties": { | ||
"securityRules": [ | ||
{ | ||
"name": "allow-ssh", | ||
"properties": { | ||
"publicIPAllocationMethod": "Dynamic" | ||
"priority": 1000, | ||
"protocol": "Tcp", | ||
"access": "Allow", | ||
"direction": "Inbound", | ||
"sourceAddressPrefix": "*", | ||
"sourcePortRange": "*", | ||
"destinationAddressPrefix": "*", | ||
"destinationPortRange": "22" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Network/virtualNetworks", | ||
"apiVersion": "2021-02-01", | ||
"name": "[concat(parameters('vmName'), '-vnet')]", | ||
"location": "[parameters('location')]", | ||
}, | ||
{ | ||
"name": "allow-4000", | ||
"properties": { | ||
"addressSpace": { | ||
"addressPrefixes": [ "10.0.0.0/16" ] | ||
}, | ||
"subnets": [ | ||
{ | ||
"name": "default", | ||
"properties": { | ||
"addressPrefix": "10.0.0.0/24" | ||
} | ||
} | ||
] | ||
"priority": 1010, | ||
"protocol": "Tcp", | ||
"access": "Allow", | ||
"direction": "Inbound", | ||
"sourceAddressPrefix": "*", | ||
"sourcePortRange": "*", | ||
"destinationAddressPrefix": "*", | ||
"destinationPortRange": "4000" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Network/networkSecurityGroups", | ||
"apiVersion": "2021-02-01", | ||
"name": "[variables('nsgName')]", | ||
"location": "[parameters('location')]", | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Network/networkInterfaces", | ||
"apiVersion": "2021-02-01", | ||
"name": "[concat(parameters('vmName'), '-nic')]", | ||
"location": "[parameters('location')]", | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Network/publicIPAddresses', variables('pipName'))]", | ||
"[resourceId('Microsoft.Network/virtualNetworks', concat(parameters('vmName'), '-vnet'))]", | ||
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" | ||
], | ||
"properties": { | ||
"ipConfigurations": [ | ||
{ | ||
"name": "ipconfig1", | ||
"properties": { | ||
"securityRules": [ | ||
{ | ||
"name": "allow-ssh", | ||
"properties": { | ||
"priority": 1000, | ||
"protocol": "Tcp", | ||
"access": "Allow", | ||
"direction": "Inbound", | ||
"sourceAddressPrefix": "*", | ||
"sourcePortRange": "*", | ||
"destinationAddressPrefix": "*", | ||
"destinationPortRange": "22" | ||
} | ||
}, | ||
{ | ||
"name": "allow-4000", | ||
"properties": { | ||
"priority": 1010, | ||
"protocol": "Tcp", | ||
"access": "Allow", | ||
"direction": "Inbound", | ||
"sourceAddressPrefix": "*", | ||
"sourcePortRange": "*", | ||
"destinationAddressPrefix": "*", | ||
"destinationPortRange": "4000" | ||
} | ||
} | ||
] | ||
"privateIPAllocationMethod": "Dynamic", | ||
"publicIPAddress": { | ||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('pipName'))]" | ||
}, | ||
"subnet": { | ||
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', concat(parameters('vmName'), '-vnet'), 'default')]" | ||
} | ||
} | ||
} | ||
], | ||
"networkSecurityGroup": { | ||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Compute/virtualMachines", | ||
"apiVersion": "2021-03-01", | ||
"name": "[parameters('vmName')]", | ||
"location": "[parameters('location')]", | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('vmName'), '-nic'))]" | ||
], | ||
"properties": { | ||
"hardwareProfile": { | ||
"vmSize": "Standard_D16_v5" | ||
}, | ||
{ | ||
"type": "Microsoft.Network/networkInterfaces", | ||
"apiVersion": "2021-02-01", | ||
"name": "[concat(parameters('vmName'), '-nic')]", | ||
"location": "[parameters('location')]", | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('vmName'), '-ip'))]", | ||
"[resourceId('Microsoft.Network/virtualNetworks', concat(parameters('vmName'), '-vnet'))]", | ||
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" | ||
], | ||
"properties": { | ||
"ipConfigurations": [ | ||
{ | ||
"name": "ipconfig1", | ||
"properties": { | ||
"privateIPAllocationMethod": "Dynamic", | ||
"publicIPAddress": { | ||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('vmName'), '-ip'))]" | ||
}, | ||
"subnet": { | ||
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', concat(parameters('vmName'), '-vnet'), 'default')]" | ||
} | ||
} | ||
} | ||
], | ||
"networkSecurityGroup": { | ||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" | ||
"osProfile": { | ||
"computerName": "[parameters('vmName')]", | ||
"adminUsername": "azureuser", | ||
"linuxConfiguration": { | ||
"disablePasswordAuthentication": true, | ||
"ssh": { | ||
"publicKeys": [ | ||
{ | ||
"path": "/home/azureuser/.ssh/authorized_keys", | ||
"keyData": "[parameters('sshPublicKey')]" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Compute/virtualMachines", | ||
"apiVersion": "2021-03-01", | ||
"name": "[parameters('vmName')]", | ||
"location": "[parameters('location')]", | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('vmName'), '-nic'))]" | ||
], | ||
"properties": { | ||
"hardwareProfile": { | ||
"vmSize": "Standard_D16_v3" | ||
}, | ||
"osProfile": { | ||
"computerName": "[parameters('vmName')]", | ||
"adminUsername": "azureuser", | ||
"linuxConfiguration": { | ||
"disablePasswordAuthentication": true, | ||
"ssh": { | ||
"publicKeys": [ | ||
{ | ||
"path": "/home/azureuser/.ssh/authorized_keys", | ||
"keyData": "[parameters('sshPublicKey')]" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"storageProfile": { | ||
"imageReference": { | ||
"publisher": "Canonical", | ||
"offer": "0001-com-ubuntu-server-jammy", | ||
"sku": "22_04-lts", | ||
"version": "latest" | ||
}, | ||
"osDisk": { | ||
"createOption": "FromImage" | ||
} | ||
}, | ||
"networkProfile": { | ||
"networkInterfaces": [ | ||
{ | ||
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('vmName'), '-nic'))]" | ||
} | ||
] | ||
} | ||
"storageProfile": { | ||
"imageReference": { | ||
"publisher": "Canonical", | ||
"offer": "0001-com-ubuntu-server-jammy", | ||
"sku": "22_04-lts", | ||
"version": "latest" | ||
}, | ||
"osDisk": { | ||
"createOption": "FromImage" | ||
} | ||
}, | ||
"networkProfile": { | ||
"networkInterfaces": [ | ||
{ | ||
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('vmName'), '-nic'))]" | ||
} | ||
] | ||
} | ||
], | ||
"outputs": { | ||
"publicIpAddress": { | ||
"type": "string", | ||
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('vmName'), '-ip'))).ipAddress]" | ||
} | ||
} | ||
} | ||
], | ||
"outputs": { | ||
"publicIpAddress": { | ||
"type": "string", | ||
"value": "[reference(variables('pipName')).ipAddress]" | ||
} | ||
} | ||
} |