Azure / Azure/azure-cli

Service connection name requirement is inconsistent with other resources by disallowing -

Open
#30,268 6 comments 0 reactions 0 assignees View on GitHub
act-observability-squad AKS Auto-Assign bug Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

Referencing [this doc](https://learn.microsoft.com/en-us/azure/aks/csi-secrets-store-identity-access?tabs=azure-cli&pivots=access-with-service-connector), a quick example command to illustrate what I am doing right now:

```bash
az aks connection create keyvault \
--connection oh-no-hyphen-is-not-allowed-now \
--resource-group my-rg-akv-on-aks \
--name my-akv-on-aks-with-sscsi \
--target-resource-group my-rg-akv-on-aks \
--vault my-akv-on-aks-with-sscsi \
--enable-csi \
--client-type none
```

Hyphens have been allowed for all the objects I have created thus far (Resource Groups, Clusters, Key Vaults, etc) but a Service Connection requires breaking my pattern due to hyphen disallow.

### Related command

az aks connection create keyvault --connection oh-no-hyphen-is-not-allowed-now

### Errors

Resource name can only contain letters (A-Z, a-z), numbers (0-9), periods ('.'), and underscores ('_')

### Issue script & Debug output

az aks connection create keyvault --connection akv-on-aks-with-sscsi --resource-group my-rg-akv-on-aks --name akv-on-aks-with-sscsi --target-resource-group my-rg-akv-on-aks --vault akv-on-aks-with-sscsi --enable-csi --client-type none --debug
cli.knack.cli: Command arguments: ['aks', 'connection', 'create', 'keyvault', '--connection', 'akv-on-aks-with-sscsi', '--resource-group', 'my-rg-akv-on-aks', '--name', 'akv-on-aks-with-sscsi', '--target-resource-group', 'my-rg-akv-on-aks', '--vault', 'akv-on-aks-with-sscsi', '--enable-csi', '--client-type', 'none', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'aks': ['azure.cli.command_modules.acs', 'azure.cli.command_modules.serviceconnector']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acs 0.604 14 77
cli.azure.cli.core: serviceconnector 0.100 20 309
cli.azure.cli.core: Total (2) 0.704 34 386
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 33 groups, 386 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : aks connection create keyvault
cli.azure.cli.core: Command table: aks connection create keyvault
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/benjaminpetersen/.azure/commands/2024-11-06.11-18-58.aks_connection_create_keyvault.22678.log'.
az_command_data_logger: command args: aks connection create keyvault --connection {} --resource-group {} --name {} --target-resource-group {} --vault {} --enable-csi --client-type {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x122dc2700>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x122e0c9a0>, .add_cache_arguments at 0x122e0cae0>, .update_breaking_change_info at 0x122e0cb80>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x122e0ca40>]
Command group 'aks connection' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.core.decorators: Suppress exception:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/azure/cli/core/decorators.py", line 79, in _wrapped_func
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
TypeError: set_exception() missing 1 required positional argument: 'fault_type'

cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
self._validation(expanded_arg)
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/knack/invocation.py", line 113, in _validation
self._validate_arg_level(parsed_ns)
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 921, in _validate_arg_level
validator(**self._build_kwargs(validator, ns))
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 910, in validate_params
validate_connection_name(namespace.connection_name)
File "/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/lib/python3.11/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 698, in validate_connection_name
raise e
azure.cli.core.azclierror.InvalidArgumentValueError: Resource name can only contain letters (A-Z, a-z), numbers (0-9), periods ('.'), and underscores ('_')

cli.azure.cli.core.azclierror: Resource name can only contain letters (A-Z, a-z), numbers (0-9), periods ('.'), and underscores ('_')
az_command_data_logger: Resource name can only contain letters (A-Z, a-z), numbers (0-9), periods ('.'), and underscores ('_')
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 2.850 seconds (init: 1.181, invoke: 1.669)

### Expected behavior

Connection should be created allowing the hyphens in name for consistency with other resources.

### Environment Summary

az --version
azure-cli 2.65.0

core 2.65.0
telemetry 1.1.0

Extensions:
interactive 1.0.0b1
scenario-guide 0.1.1

Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.65.0_2/libexec/bin/python'
Extensions directory '/Users/someuser/.azure/cliextensions'

Python (Darwin) 3.11.10 (main, Sep 7 2024, 01:03:31) [Clang 16.0.0 (clang-1600.0.26.3)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

Thanks! 🐶

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.