Skip to content

Commit

Permalink
Adding Windows10 with NVidia Extension example (#1232)
Browse files Browse the repository at this point in the history
* Adding Windows10 with NVidia Extension example

Adding Windows10 with Nvidia GPU Driver Extension example as a condition

* added trailing newline

added trailing newline
  • Loading branch information
fberson authored Dec 27, 2020
1 parent c0039d8 commit ea58b1f
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//define parameters
param localAdminName string = 'localadmin'
param localAdminPassword string {
secure: true
}
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: {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"localAdminName": {
"type": "string",
"defaultValue": "localadmin"
},
"localAdminPassword": {
"type": "secureString"
},
"vnetName": {
"type": "string",
"defaultValue": "bicep-demo-vnet"
},
"vmSku": {
"type": "string",
"defaultValue": "Standard_NV6"
},
"vmOS": {
"type": "string",
"defaultValue": "20h2-ent"
},
"installNVidiaGPUDriver": {
"type": "bool",
"defaultValue": true
},
"vmName": {
"type": "string",
"defaultValue": "bicep-demo-vm"
}
},
"functions": [],
"variables": {
"defaultLocation": "[resourceGroup().location]",
"defaultVmNicName": "[format('{0}-nic', parameters('vmName'))]",
"vnetConfig": {
"vnetprefix": "10.0.0.0/16",
"subnet": {
"name": "bicep-demo-subnet",
"subnetPrefix": "10.0.66.0/24"
}
},
"privateIPAllocationMethod": "Dynamic"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-05-01",
"name": "[parameters('vnetName')]",
"location": "[variables('defaultLocation')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('vnetConfig').vnetprefix]"
]
},
"subnets": [
{
"name": "[variables('vnetConfig').subnet.name]",
"properties": {
"addressPrefix": "[variables('vnetConfig').subnet.subnetPrefix]"
}
}
]
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2017-06-01",
"name": "[variables('defaultVmNicName')]",
"location": "[variables('defaultLocation')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[format('{0}/subnets/{1}', resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName')), variables('vnetConfig').subnet.name)]"
},
"privateIPAllocationMethod": "[variables('privateIPAllocationMethod')]"
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]"
]
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-07-01",
"name": "[parameters('vmName')]",
"location": "[variables('defaultLocation')]",
"properties": {
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('localAdminName')]",
"adminPassword": "[parameters('localAdminPassword')]"
},
"hardwareProfile": {
"vmSize": "[parameters('vmSku')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsDesktop",
"offer": "Windows-10",
"sku": "[parameters('vmOS')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
}
},
"licenseType": "Windows_Client",
"networkProfile": {
"networkInterfaces": [
{
"properties": {
"primary": true
},
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('defaultVmNicName'))]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('defaultVmNicName'))]"
]
},
{
"condition": "[parameters('installNVidiaGPUDriver')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2020-06-01",
"name": "[format('{0}/NvidiaGpuDriverWindows', parameters('vmName'))]",
"location": "[variables('defaultLocation')]",
"properties": {
"publisher": "Microsoft.HpcCompute",
"type": "NvidiaGpuDriverWindows",
"typeHandlerVersion": "1.3",
"autoUpgradeMinorVersion": true,
"settings": {}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]"
]
}
]
}
4 changes: 4 additions & 0 deletions docs/examples/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@
"filePath": "201/wvd-backplane-with-network-and-storage-and-monitoring/main.bicep",
"description": "201/wvd-backplane-with-network-and-storage-and-monitoring"
},
{
"filePath": "201/vm-windows10-with-nvidia-gpu-extension-and-condition/main.bicep",
"description": "201/vm-windows10-with-nvidia-gpu-extension-and-condition"
},
{
"filePath": "301/function-app-with-custom-domain-managed-certificate/main.bicep",
"description": "301/function-app-with-custom-domain-managed-certificate"
Expand Down

0 comments on commit ea58b1f

Please sign in to comment.