Hi @Ran Bi
Thank you for reaching out to Microsoft Q&A.
The error you are encountering during the ARM/Bicep template deployment is a preflight validation failure, and although it appears to reference the deployment name, the issue is not actually with the deployment name itself. The provided deployment name already satisfies the required naming constraints (allowed characters, valid start, and valid end). This error commonly occurs because one of the resource names defined inside the ARM/Bicep template violates the naming rules enforced by the specific Azure resource provider. During preflight validation, Azure evaluates all resource name properties after resolving expressions such as concat(), format(), uniqueString(), or region-based suffixes. If the final resolved resource name starts or ends with an invalid character, contains unintended separators, or does not comply with provider-specific constraints, the deployment fails with a generic “Name field” error message. This behavior is misleading but expected, as the ARM engine surfaces provider-level validation errors using a common message format.
Refer below points to resolve this issue or this is the workaround
1. Identify the exact resource causing the failure
Review the deployment Operation details or Inner errors in the Azure Portal. The failing entry will clearly indicate the targetResource.resourceType and targetResource.resourceName, which is the actual name that violates the rule. This is the most reliable way to pinpoint the problematic resource.
2. Validate the final resolved resource name, not just the parameter
If the resource name is dynamically constructed using expressions such as concat(), format(), uniqueString(), or appended with region names (for example westus2), ensure that:
The name starts with an alphanumeric character
The name ends with an alphanumeric character or underscore
There are no trailing or leading separators such as - or
Example of a problematic pattern:
name: '${prefix}-${location}'
If prefix already ends with -, the final name becomes invalid.
3. Account for resource provider–specific naming rules Some Azure resource providers enforce stricter naming rules than generic ARM validation. Even if the name looks valid at first glance, the provider may reject it during preflight validation. Always cross-check the naming rules for the specific resource type being deployed (for example, Key Vault, Managed HSM, Storage Account, App Service).
4. Normalize and sanitize dynamic names defensively as a best practice, sanitize dynamically generated names to avoid invalid characters or positions. For example:
var sanitizedName = toLower(replace(replace(rawName, '--', '-'), '-$', ''))