Created
August 6, 2018 10:14
-
-
Save lzghzr/28238ecb58c4c110144159b1a4246824 to your computer and use it in GitHub Desktop.
Azure模板
This file contains hidden or 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
{ | |
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"adminUsername": { | |
"type": "string" | |
}, | |
"adminPublicKey": { | |
"type": "string" | |
}, | |
"SSHPort": { | |
"type": "string" | |
} | |
}, | |
"variables": { | |
"location": "eastasia", | |
"virtualMachineName": "myVM", | |
"virtualMachineSize": "Standard_B1s", | |
"virtualNetworkName": "myVNet", | |
"subnetName": "mySubnet", | |
"addressPrefix": "10.0.0.0/24", | |
"subnetPrefix": "10.0.0.0/24", | |
"networkInterfaceName": "myNI", | |
"networkSecurityGroupName": "myNSG", | |
"diskName": "myDisk", | |
"diskSizeGB": "64", | |
"lbName": "myLB", | |
"lbID": "[resourceId('Microsoft.Network/loadBalancers',variables('lbName'))]", | |
"ipv4FrontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEndIPv4')]", | |
"ipv6FrontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEndIPv6')]", | |
"ipv4LbBackendPoolID": "[concat(variables('lbID'),'/backendAddressPools/BackendPoolIPv4')]", | |
"ipv6LbBackendPoolID": "[concat(variables('lbID'),'/backendAddressPools/BackendPoolIPv6')]", | |
"publicIpv4AddressName": "myIPv4PublicIP", | |
"publicIPv6AddressName": "myIPv6PublicIP" | |
}, | |
"resources": [ | |
{ | |
"name": "[variables('virtualMachineName')]", | |
"type": "Microsoft.Compute/virtualMachines", | |
"apiVersion": "2018-04-01", | |
"location": "[variables('location')]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]" | |
], | |
"properties": { | |
"osProfile": { | |
"computerName": "[variables('virtualMachineName')]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"linuxConfiguration": { | |
"disablePasswordAuthentication": "true", | |
"ssh": { | |
"publicKeys": [ | |
{ | |
"path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]", | |
"keyData": "[parameters('adminPublicKey')]" | |
} | |
] | |
} | |
} | |
}, | |
"hardwareProfile": { | |
"vmSize": "[variables('virtualMachineSize')]" | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "Canonical", | |
"offer": "UbuntuServer", | |
"sku": "18.04-LTS", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"createOption": "fromImage", | |
"name": "[variables('diskName')]", | |
"diskSizeGB": "[variables('diskSizeGB')]", | |
"managedDisk": { | |
"storageAccountType": "Premium_LRS" | |
} | |
}, | |
"dataDisks": [] | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]" | |
} | |
] | |
} | |
} | |
}, | |
{ | |
"name": "[variables('virtualNetworkName')]", | |
"type": "Microsoft.Network/virtualNetworks", | |
"apiVersion": "2018-02-01", | |
"location": "[variables('location')]", | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"[variables('addressPrefix')]" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[variables('subnetName')]", | |
"properties": { | |
"addressPrefix": "[variables('subnetPrefix')]" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"name": "[variables('networkInterfaceName')]", | |
"type": "Microsoft.Network/networkInterfaces", | |
"apiVersion": "2018-04-01", | |
"location": "[variables('location')]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]", | |
"[concat('Microsoft.Network/loadBalancers/', variables('lbName'))]", | |
"[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]" | |
], | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipv4IPConfig", | |
"properties": { | |
"subnet": { | |
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets',variables('virtualNetworkName'), variables('subnetName'))]" | |
}, | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[variables('ipv4LbBackendPoolID')]" | |
} | |
], | |
"loadBalancerInboundNatRules": [ | |
{ | |
"id": "[concat(variables('lbID'),'/inboundNatRules/IPv4NatRules_SSH')]" | |
}, | |
{ | |
"id": "[concat(variables('lbID'),'/inboundNatRules/IPv4NatRules_HTTP')]" | |
}, | |
{ | |
"id": "[concat(variables('lbID'),'/inboundNatRules/IPv4NatRules_HTTPS')]" | |
} | |
], | |
"privateIPAddressVersion": "IPv4", | |
"privateIPAllocationMethod": "Dynamic" | |
} | |
}, | |
{ | |
"name": "ipv6IPConfig", | |
"properties": { | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[variables('ipv6LbBackendPoolID')]" | |
} | |
], | |
"loadBalancerInboundNatRules": [ | |
{ | |
"id": "[concat(variables('lbID'),'/inboundNatRules/IPv6NatRules_HTTP')]" | |
}, | |
{ | |
"id": "[concat(variables('lbID'),'/inboundNatRules/IPv6NatRules_HTTPS')]" | |
} | |
], | |
"privateIPAddressVersion": "IPv6", | |
"privateIPAllocationMethod": "Dynamic" | |
} | |
} | |
], | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" | |
} | |
} | |
}, | |
{ | |
"apiVersion": "2017-08-01", | |
"name": "[variables('lbName')]", | |
"type": "Microsoft.Network/loadBalancers", | |
"location": "[variables('location')]", | |
"sku": { | |
"name": "Basic" | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPv6AddressName'))]", | |
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIpv4AddressName'))]" | |
], | |
"properties": { | |
"frontendIPConfigurations": [ | |
{ | |
"name": "LoadBalancerFrontEndIPv4", | |
"properties": { | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIpv4AddressName'))]" | |
} | |
} | |
}, | |
{ | |
"name": "LoadBalancerFrontEndIPv6", | |
"properties": { | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPv6AddressName'))]" | |
} | |
} | |
} | |
], | |
"backendAddressPools": [ | |
{ | |
"name": "BackendPoolIPv4" | |
}, | |
{ | |
"name": "BackendPoolIPv6" | |
} | |
], | |
"inboundNatRules": [ | |
{ | |
"name": "IPv4NatRules_SSH", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('ipv4FrontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": "[parameters('SSHPort')]", | |
"backendPort": 22, | |
"enableFloatingIP": false | |
} | |
}, | |
{ | |
"name": "IPv4NatRules_HTTP", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('ipv4FrontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 80, | |
"backendPort": 80, | |
"enableFloatingIP": false | |
} | |
}, | |
{ | |
"name": "IPv4NatRules_HTTPS", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('ipv4FrontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 443, | |
"backendPort": 443, | |
"enableFloatingIP": false | |
} | |
}, | |
{ | |
"name": "IPv6NatRules_HTTP", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('ipv6FrontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 80, | |
"backendPort": 80, | |
"enableFloatingIP": false | |
} | |
}, | |
{ | |
"name": "IPv6NatRules_HTTPS", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('ipv6FrontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 443, | |
"backendPort": 443, | |
"enableFloatingIP": false | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"name": "[variables('publicIpv4AddressName')]", | |
"type": "Microsoft.Network/publicIpAddresses", | |
"apiVersion": "2017-08-01", | |
"location": "[variables('location')]", | |
"properties": { | |
"publicIPAddressVersion": "IPv4", | |
"publicIpAllocationMethod": "Dynamic", | |
"idleTimeoutInMinutes": 5 | |
}, | |
"sku": { | |
"name": "Basic" | |
} | |
}, | |
{ | |
"name": "[variables('publicIPv6AddressName')]", | |
"type": "Microsoft.Network/publicIPAddresses", | |
"apiVersion": "2017-08-01", | |
"location": "[variables('location')]", | |
"properties": { | |
"publicIPAddressVersion": "IPv6", | |
"publicIPAllocationMethod": "Dynamic", | |
"idleTimeoutInMinutes": 5 | |
}, | |
"sku": { | |
"name": "Basic" | |
} | |
}, | |
{ | |
"name": "[variables('networkSecurityGroupName')]", | |
"type": "Microsoft.Network/networkSecurityGroups", | |
"apiVersion": "2018-01-01", | |
"location": "[variables('location')]", | |
"properties": { | |
"securityRules": [ | |
{ | |
"name": "HTTP", | |
"properties": { | |
"priority": 100, | |
"protocol": "TCP", | |
"access": "Allow", | |
"direction": "Inbound", | |
"sourceApplicationSecurityGroups": [], | |
"destinationApplicationSecurityGroups": [], | |
"sourceAddressPrefix": "Internet", | |
"sourcePortRange": "*", | |
"destinationAddressPrefix": "*", | |
"destinationPortRanges": [ | |
"80", | |
"443" | |
] | |
} | |
}, | |
{ | |
"name": "SSH", | |
"properties": { | |
"priority": 1000, | |
"protocol": "TCP", | |
"access": "Allow", | |
"direction": "Inbound", | |
"sourceApplicationSecurityGroups": [], | |
"destinationApplicationSecurityGroups": [], | |
"sourceAddressPrefix": "Internet", | |
"sourcePortRange": "*", | |
"destinationAddressPrefix": "*", | |
"destinationPortRange": "22" | |
} | |
} | |
] | |
} | |
} | |
], | |
"outputs": { | |
"adminUsername": { | |
"type": "string", | |
"value": "[parameters('adminUsername')]" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment