mspnp / AzureNamingTool

The Azure Naming Tool is a .NET 8 Blazor application, with a RESTful API. The UI consists of several pages to allow the configuration and generation of Azure Resource names. The API provides a programmatic interface for the functionality.
https://aka.ms/azurenamingtool
MIT License
308 stars 604 forks source link

Instance Length and VM Delimiters #48

Closed koalajama closed 7 months ago

koalajama commented 7 months ago

Tool version 3.2.0

Describe the bug Bug #1 I have my instance minimum and maximum set to 2. The intention is to require a two digit instance id. (01-99). The tool allows a single digit instance number. One attachment shows the instance settings, the other is the generated names log that has single digit instance ids listed.

Bug #2 When generating VM names, it doesn't seem to be consistently honoring the delimiter requirements. I was able to generate a VM with dash delimiters in the name. I cleared the cache and it persisted. Attachment shows the generated name log, the items circled in red were after I cleared the cache.

Expected behavior 1 - Would only allow a two digit number. 2 - Would not input dashes in the name.

Screenshots If applicable, add screenshots to help explain your problem. ANT_GeneratedNames ANT_InstanceComponent

Installation Method Azure Web App

BryanSoltis commented 7 months ago

Hi @koalajama,

Thank you for your feedback. I looked at the code and found a few issues.

  1. The site was not properly validating the length of a component value when a name was generated. It was when the component options were entered (on the Configuration page), but not the actual Generate page. I have updated the code to properly check if the value meets the min/max length properties for the component. The Generate page will not allow generation (the Generate button will be disabled) if the length does not meet the requirements.

  2. The site was actually functioning properly, however, the messaging was wrong. When an attempt to generate a name is made, it uses the selected delimiter, along with the supplied values. If the regex fails, it will remove the delimiter and try again. (This is to handle when the length is too long for the resource type, as defined in the regex). In the example you provided, the "removed delimiter" record was over the 15-character limit for Windows VMs, so the delimiter was removed.

I have updated the message to the following (rather than the "delimiter is not allowed message):

"The specified delimiter was removed. This is often caused by the length of the name exceeding the max length and the delimiter removed to shorten the name."

These changes will be included in the next version,

Thank you!