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

Ability to refine RegEx / provide options to make more specific #9

Closed donhaji closed 10 months ago

donhaji commented 11 months ago

Is your feature request related to a problem? Please describe. Feature Request. The RegEx generated in the Reference section seems to generic and is far better to be broken down into options that match specific lookups for resources e.g.

Example: uks-dev-glb-hub-lvm-1 ComponentsLocation:UK South (uks) Environment:Development (dev) ProjAppSvc:Global Devops (glb) Subscriptions:Hub Gateway (hub) Type:Compute/virtualMachines (lvm) Instance:001 RegEx ^(?!.[.]$)(?!.-$)[^\/[]:|<>+=;,\?@&_*]{1,64}$

The Regex is too generic and will match almost any resource.

Describe the solution you'd like A clear and concise description of what you want to happen.

Either some more generated patterns that hardcode in specific details e.g. RegEx Patterns

Global ^(?!.[.]$)(?!.-$)[^\/[]:|<>+=;,\?@&_*]{1,64}$ Specific ^\w{1,3}-\w{1,3}-\w{1,3}-\w{1,3}-lvm-01 (or alternative regex)

Describe alternatives you've considered Alternatives is to create the specific RegEx manually.

Additional context Devops PIpelines can help utilise the regex better when using multiple Landing Zones with standard approach to naming. E.g. Subscriptions Landing Zone A Landing Zone B Landing Zone C

All Landing Zones have similar if not the same resources with potentially the same name. Having RegEx patterns when using Az Devops allows for better pipeline templating and control over resource generation.

jamasten commented 10 months ago

Hi @donhaji. Thank you for your feedback. Can you please elaborate on how or why you need additional regex validations? Currently the built-in regex validates the name based on the Azure resource. So even though your naming convention might use a delimiter, the regex only cares that it's a valid Azure resource name. Also, the Azure Naming Tool will only generate a name that follows your configuration. So, checking component lengths and your delimiter with an additional regex check has no value as long as you configured your naming convention in the tool correctly. Please let us know. Thanks!

donhaji commented 10 months ago

Hi @jamasten - so the validation is all good and well. However, the other use case i would recommend is for matching / searching for resources once they have been created. This helps aid scripting and lookups for resources in Azure e.g. Az Cli.

BryanSoltis commented 10 months ago

Hi @donhaji,

The current version of the tool does allow for searching the Generated Names for a specific value. Entered text is searched against the Created By, Generated Name, Resource Type, and Components fields.

image

Are you requesting a new API function to search for names, as well?

BryanSoltis commented 10 months ago

Closed due to inactivity.