-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
114 lines (107 loc) · 2.49 KB
/
main.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
104
105
106
107
108
109
110
111
112
113
114
//define parameters
param localAdminName string = 'localadmin'
@secure()
param localAdminPassword string
param vnetName string = 'bicep-demo-vnet'
param vmSku string = 'Standard_NV6'
param vmOS string = '20h2-ent'
param installNVidiaGPUDriver bool = true
param vmName string = 'bicep-demo-vm'
//define variables
var defaultLocation = resourceGroup().location
var defaultVmNicName = '${vmName}-nic'
var vnetConfig = {
vnetprefix: '10.0.0.0/16'
subnet: {
name: 'bicep-demo-subnet'
subnetPrefix: '10.0.66.0/24'
}
}
var privateIPAllocationMethod = 'Dynamic'
//Create vnet
resource vnet 'Microsoft.Network/virtualNetworks@2020-05-01' = {
name: vnetName
location: defaultLocation
properties: {
addressSpace: {
addressPrefixes: [
vnetConfig.vnetprefix
]
}
subnets: [
{
name: vnetConfig.subnet.name
properties: {
addressPrefix: vnetConfig.subnet.subnetPrefix
}
}
]
}
}
//create nic
resource vmNic 'Microsoft.Network/networkInterfaces@2017-06-01' = {
name: defaultVmNicName
location: defaultLocation
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
subnet: {
id: '${vnet.id}/subnets/${vnetConfig.subnet.name}'
}
privateIPAllocationMethod: privateIPAllocationMethod
}
}
]
}
}
//create VM
resource vm 'Microsoft.Compute/virtualMachines@2019-07-01' = {
name: vmName
location: defaultLocation
properties: {
osProfile: {
computerName: vmName
adminUsername: localAdminName
adminPassword: localAdminPassword
}
hardwareProfile: {
vmSize: vmSku
}
storageProfile: {
imageReference: {
publisher: 'MicrosoftWindowsDesktop'
offer: 'Windows-10'
sku: vmOS
version: 'latest'
}
osDisk: {
createOption: 'FromImage'
}
}
licenseType: 'Windows_Client'
networkProfile: {
networkInterfaces: [
{
properties: {
primary: true
}
id: vmNic.id
}
]
}
}
}
//add Nvidia drivers using extension in condition is true
resource vmgpu 'Microsoft.Compute/virtualMachines/extensions@2020-06-01' = if (installNVidiaGPUDriver) {
name: '${vm.name}/NvidiaGpuDriverWindows'
location: defaultLocation
properties: {
publisher: 'Microsoft.HpcCompute'
type: 'NvidiaGpuDriverWindows'
typeHandlerVersion: '1.3'
autoUpgradeMinorVersion: true
settings: {}
}
}