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.
This rule finds when an admin user name is set to a literal value.
Use the following value in the Bicep configuration file to customize rule settings:
adminusername-should-not-be-literal
Don't use a literal value or an expression that evaluates to a literal value. Instead, create a parameter for the user name and assign it to the admin user name.
The following example fails this test because the user name is a literal value.
resource vm 'Microsoft.Compute/virtualMachines@2023-03-01' = {
name: 'name'
location: location
properties: {
osProfile: {
adminUsername: 'adminUsername'
}
}
}
The next example fails this test because the expression evaluates to a literal value when the default value is used.
var defaultAdmin = 'administrator'
resource vm 'Microsoft.Compute/virtualMachines@2023-03-01' = {
name: 'name'
location: location
properties: {
osProfile: {
adminUsername: defaultAdmin
}
}
}
This example passes this test.
@secure()
param adminUsername string
param location string
resource vm 'Microsoft.Compute/virtualMachines@2023-03-01' = {
name: 'name'
location: location
properties: {
osProfile: {
adminUsername: adminUsername
}
}
}
For more information about the linter, see Use Bicep linter.