-
Notifications
You must be signed in to change notification settings - Fork 1
/
vm.bicep
103 lines (97 loc) · 2.57 KB
/
vm.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// All Parameters required for VM Deployment is given here.
param adminUserName string
@secure()
param adminPassword string
param dnsLabelPrefix string
@description('location for all resources')
param location string = resourceGroup().location
// All Variables required for VM Deployment is given here.
var windowsOSVersion = '2016-Datacenter'
var vmSize = 'Standard_B2s'
var nicName = 'myVMNic'
var publicIPAddressName = 'myPublicIP'
var vmName = 'Win2016Server'
var networkSecurityGroupName = 'default-NSG'
// Passing parameters and variables for network resources.
param vnet object
param subnetName string = 'Subnet1'
var vnetName = last(split(vnet.resourceId, '/'))
var subnetId = resourceId(vnet.resourceGroupName, 'Microsoft.Network/virtualNetworks/subnets', vnetName, subnetName)
// ------------------------------------
// Azure Public IP Resource is created.
// ------------------------------------
resource pip 'Microsoft.Network/publicIPAddresses@2020-06-01' = {
name: publicIPAddressName
location: location
properties: {
publicIPAllocationMethod: 'Dynamic'
dnsSettings: {
domainNameLabel: dnsLabelPrefix
}
}
}
// --------------------------------------------
// Azure Network Interface Resource is created.
// --------------------------------------------
resource nInter 'Microsoft.Network/networkInterfaces@2020-06-01' = {
name: nicName
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
id: pip.id
}
subnet: {
id: subnetId
}
}
}
]
}
}
// --------------------------------------------------
// Azure Windows Virtual Machine Resource is created.
// --------------------------------------------------
resource VM 'Microsoft.Compute/virtualMachines@2020-06-01' = {
name: vmName
location: location
properties: {
hardwareProfile: {
vmSize: vmSize
}
osProfile: {
computerName: vmName
adminUsername: adminUserName
adminPassword: adminPassword
}
storageProfile: {
imageReference: {
publisher: 'MicrosoftWindowsServer'
offer: 'WindowsServer'
sku: windowsOSVersion
version: 'latest'
}
osDisk: {
createOption: 'FromImage'
}
dataDisks: [
{
diskSizeGB: 128
lun: 0
createOption: 'Empty'
}
]
}
networkProfile: {
networkInterfaces: [
{
id: nInter.id
}
]
}
}
}