To deploy a Windows or Linux Virtual Machine to Azure, using Bicep, it's easier if the vm module splitted into two separate files for Windows and Linux.
To create a Virtual Machine, it's also needed to create several resources, such as Virtual Network, Public IP, Network Security Group, Network Interface, and Storage Account.
In this project, there is a vm_commons.bicep file that contains the resources that are common to both Windows and Linux Virtual Machines.
The vm_windows.bicep file contains only the Windows Virtual Machine resource, and the reference to the vm_commons.bicep module.
The vm_linux.bicep file contains only the Linux Virtual Machine resource, and the reference to the vm_commons.bicep module.
vm.bicepparam is the parameter file for both of the Virtual Machine modules.
Both vm_windows.bicep and vm_linux.bicep files have the following parameters to create common resources and vm specific resources:
param creds object
param common object
The creds
parameter is used to pass username
and password
, or username
and sshkey
pairs for the Virtual Machine, based on the Operating System.
The common
parameter is used to pass the addressPrefix
, dnsLabelPrefix
, virtualNetworkName
, subnetName
, publicIpName
, networkSecurityGroupName
, nicName
, publicIPAllocationMethod
, subnetPrefix
, publicIpSku
and storageAccountName
for the Virtual Machine.