Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Virtual machines shouldn't use preview images. This rule checks the following properties under "imageReference" and fails if any of them contain the string "preview":
- offer
- sku
- version
Linter rule code
To customize rule settings, use the following value in the Bicep configuration file
use-stable-vm-image
Solution
The following example fails this test.
param location string = resourceGroup().location
resource vm 'Microsoft.Compute/virtualMachines@2024-03-01' = {
name: 'virtualMachineName'
location: location
properties: {
storageProfile: {
imageReference: {
offer: 'WindowsServer-preview'
sku: '2019-Datacenter-preview'
version: 'preview'
}
}
}
}
You can fix it by using an image that doesn't contain the string preview in the imageReference.
param location string = resourceGroup().location
resource vm 'Microsoft.Compute/virtualMachines@2024-03-01' = {
name: 'virtualMachineName'
location: location
properties: {
storageProfile: {
imageReference: {
offer: 'WindowsServer'
sku: '2019-Datacenter'
version: 'latest'
}
}
}
}
Next steps
For more information about the linter, see Use Bicep linter.