Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
arm-vm-windows-wsl2/azuredeploy.json
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
258 lines (258 sloc)
11.7 KB
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
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"adminUsername": { | |
"type": "string", | |
"metadata": { | |
"description": "Username for the Virtual Machine." | |
} | |
}, | |
"adminPassword": { | |
"type": "securestring", | |
"metadata": { | |
"description": "Password for the Virtual Machine." | |
} | |
}, | |
"dnsLabelPrefix": { | |
"type": "string", | |
"metadata": { | |
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine." | |
} | |
}, | |
"windowsOSVersion": { | |
"type": "string", | |
"defaultValue": "20h2-ent", | |
"allowedValues": [ | |
"19h1-ent", | |
"19h1-ent-gensecond", | |
"19h2-ent", | |
"19h2-ent-g2", | |
"20h1-ent", | |
"20h1-ent-g2", | |
"20h2-ent", | |
"20h2-ent-g2" | |
], | |
"metadata": { | |
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version." | |
} | |
}, | |
"vmSize": { | |
"type": "string", | |
"defaultValue": "Standard_D4s_v3", | |
"metadata": { | |
"description": "Size of the virtual machine." | |
} | |
}, | |
"patchMode": { | |
"type": "string", | |
"defaultValue": "AutomaticByOS", | |
"metadata": { | |
"description": "Patch mode for the OS" | |
} | |
}, | |
"location": { | |
"type": "string", | |
"defaultValue": "[resourceGroup().location]", | |
"metadata": { | |
"description": "Location for all resources." | |
} | |
} | |
}, | |
"variables": { | |
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'sawinvm')]", | |
"nicName": "myVMNic", | |
"addressPrefix": "10.0.0.0/16", | |
"subnetName": "Subnet", | |
"subnetPrefix": "10.0.0.0/24", | |
"publicIPAddressName": "myPublicIP", | |
"vmName": "SimpleWinVM", | |
"virtualNetworkName": "MyVNET", | |
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]", | |
"networkSecurityGroupName": "default-NSG", | |
"customScript": "$ProgressPreference='SilentlyContinue'\r\nEnable-WindowsOptionalFeature -Online -NoRestart -FeatureName Microsoft-Windows-Subsystem-Linux\r\nEnable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart\r\nInvoke-WebRequest https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -OutFile c:\\wsl_update_x64.msi -UseBasicParsing\r\nInvoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile c:\\ubuntu2004.appx -UseBasicParsing\r\nAdd-AppxPackage c:\\ubuntu2004.appx\r\nSet-Content -Path c:\\config2.ps1 -Value \"msiexec /i c:\\wsl_update_x64.msi /qn`r`nsleep 5`r`nwsl --set-default-version 2`r`nubuntu2004.exe install --root\"\r\n$action = New-ScheduledTaskAction -Execute powershell.exe -Argument \"-File c:\\config2.ps1\"\r\n$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest -LogonType S4U\r\n$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:01\r\n$definition = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger\r\nRegister-ScheduledTask -TaskName \"install-ubuntu\" -InputObject $definition\r\nSet-ExecutionPolicy RemoteSigned -Force\r\nRestart-Computer -Force\r\n", | |
"timeZone": "GMT Standard Time" | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('storageAccountName')]", | |
"location": "[parameters('location')]", | |
"sku": { | |
"name": "Standard_LRS" | |
}, | |
"kind": "Storage", | |
"properties": {} | |
}, | |
{ | |
"type": "Microsoft.Network/publicIPAddresses", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('publicIPAddressName')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"publicIPAllocationMethod": "Dynamic", | |
"dnsSettings": { | |
"domainNameLabel": "[parameters('dnsLabelPrefix')]" | |
} | |
} | |
}, | |
{ | |
"comments": "Default Network Security Group for template", | |
"type": "Microsoft.Network/networkSecurityGroups", | |
"apiVersion": "2019-08-01", | |
"name": "[variables('networkSecurityGroupName')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"securityRules": [ | |
{ | |
"name": "default-allow-3389", | |
"properties": { | |
"priority": 1000, | |
"access": "Allow", | |
"direction": "Inbound", | |
"destinationPortRange": "3389", | |
"protocol": "Tcp", | |
"sourcePortRange": "*", | |
"sourceAddressPrefix": "*", | |
"destinationAddressPrefix": "*" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/virtualNetworks", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('virtualNetworkName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" | |
], | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"[variables('addressPrefix')]" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[variables('subnetName')]", | |
"properties": { | |
"addressPrefix": "[variables('subnetPrefix')]", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/networkInterfaces", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('nicName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", | |
"[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" | |
], | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipconfig1", | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" | |
}, | |
"subnet": { | |
"id": "[variables('subnetRef')]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Compute/virtualMachines", | |
"apiVersion": "2020-06-01", | |
"name": "[variables('vmName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", | |
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]" | |
], | |
"properties": { | |
"hardwareProfile": { | |
"vmSize": "[parameters('vmSize')]" | |
}, | |
"osProfile": { | |
"computerName": "[variables('vmName')]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"adminPassword": "[parameters('adminPassword')]", | |
"customData": "[base64(variables('customScript'))]", | |
"windowsConfiguration": { | |
"enableAutomaticUpdates": true, | |
"provisionVMAgent": true, | |
"timeZone": "[variables('timeZone')]", | |
"patchSettings": { | |
"patchMode": "[parameters('patchMode')]" | |
}, | |
"additionalUnattendContent": [ | |
{ | |
"passName": "OobeSystem", | |
"componentName": "Microsoft-Windows-Shell-Setup", | |
"settingName": "FirstLogonCommands", | |
"content": "<FirstLogonCommands><SynchronousCommand><CommandLine>cmd /c \"copy C:\\AzureData\\CustomData.bin C:\\Config.ps1\"</CommandLine><Description>copy</Description><Order>1</Order></SynchronousCommand><SynchronousCommand><CommandLine>%windir%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -file C:\\Config.ps1</CommandLine><Description>script</Description><Order>2</Order></SynchronousCommand></FirstLogonCommands>" | |
}, | |
{ | |
"passName": "OobeSystem", | |
"componentName": "Microsoft-Windows-Shell-Setup", | |
"settingName": "AutoLogon", | |
"content": "[concat('<AutoLogon><Password><Value>', parameters('adminPassword'), '</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>', parameters('adminUserName'), '</Username></AutoLogon>')]" | |
} | |
] | |
} | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "MicrosoftWindowsDesktop", | |
"offer": "Windows-10", | |
"sku": "[parameters('windowsOSVersion')]", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"createOption": "FromImage" | |
}, | |
"dataDisks": [ | |
{ | |
"diskSizeGB": 1023, | |
"lun": 0, | |
"createOption": "Empty" | |
} | |
] | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" | |
} | |
] | |
}, | |
"diagnosticsProfile": { | |
"bootDiagnostics": { | |
"enabled": true, | |
"storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob]" | |
} | |
} | |
} | |
} | |
], | |
"outputs": { | |
"hostname": { | |
"type": "string", | |
"value": "[reference(variables('publicIPAddressName')).dnsSettings.fqdn]" | |
} | |
} | |
} |