Sometimes I'll add a resource to my Bicep and it'll fail because the name is incorrect.
For example, a VM shutdown schedule:
resource vmAutoShutdown 'Microsoft.DevTestLab/schedules@2018-09-15' = {
name: '${vm.name}-autoshutdown'
location: location
//<snip>
}
That name isn't allowed - it has to be 'shutdown-computevm-${vm.name}'
Or virus scanning for an Azure Blob Storage container:
resource defenderForStorageSettings 'Microsoft.Security/DefenderForStorageSettings@2022-12-01-preview' = if (enableVirusScanning) {
name: '${storage.name}-antivirus'
scope: storage
//<snip>
}
Nope, must be name: 'current'
.
Is there a way to find this out or validate the names that doesn't require running an actual deployment?
For this, there is no easy way to know in my experience. What I usually do is check the Azure Template Reference for the specific Azure resource I want to deploy, You can easily find all the available options for the Azure resources in Bicep, ARM, and Terraform from this documentation.
https://learn.microsoft.com/en-us/azure/templates/
Then I also refer to the Azure Resource Name rules documentation to understand different naming requirements for each service I use. There are various restrictions depending on the service you use. You can find the Azure resource naming rules and restrictions in this documentation.
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules