Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

Need validation of project name length at the time it's specified #20691

Open charris-msft opened 2 years ago

charris-msft commented 2 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

There was an error because my project name was too long. I incremented it after a previous failure from todo-python-mongo2 to todo-python-mongo2 which exceeded the length limit.

We should check for this and error out as early as possible, like when we prompt the user for it. In addition, we should only suggest a name that will meeting the length (and other) requirements, regardless of what the parent folder is called.

Command Name az deployment sub create

Errors:

{'code': 'InvalidTemplate', 'message': "Deployment template validation failed: 'The provided value for the template parameter 'basename' at line '17' and column '21' is not valid. Length of the value should be less than or equal to '17'. Please see https://aka.ms/arm-template/#parameters for usage details.'.", 'additionalInfo': [{'type': 'TemplateViolation', 'info': {'lineNumber': 17, 'linePosition': 21, 'path': 'properties.template.parameters.basename.maxLength'}}]}

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Environment Summary

Windows-10-10.0.22000-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.31.0

Extensions:
azure-dev 0.0.1b70
rdbms-connect 0.1.4

Additional Context

zhoxing-ms commented 2 years ago

Deployment template validation failed

@charris-msft In fact, this is a verification error in phase preflight. At this time, the error has been notified in advance before the real resource deployment. Therefore, I think this has prompted this error before creating the resource. Do you have any other suggestions for this?