[BUG] Run Command does not work for email accounts that start with underscore
Describe the bug
The Run Command feature does not work for accounts with email addresses that begin with an underscore (e.g., "[email protected]"). The error message returned is as follows:
(KubernetesOperationError) Failed to run command in managed cluster due to kubernetes failure. details: Pod "command-d8a090f2f77741d58feb9382d5f09745" is invalid: metadata.labels: Invalid value: "_myemail_mail.com": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?') Code: KubernetesOperationError
The error exists both in az aks command invoke and Run Command in the portal.
To Reproduce Steps to reproduce the behavior:
- Create an email address that starts with an underscore.
- Run
az aks command invoke --resource-group $rg --name $aksname --command "kubectl get pods -n kube-system"or any command usingRun Command
Expected behavior The "Run Command" feature and "az aks command invoke" should allow commands to be executed from accounts with email addresses starting with an underscore (_).
Environment (please complete the following information):
- CLI Version 2.70.0
- Kubernetes version 1.30.9
@anielii confirming that this happens because the Azure user account has an email (and user ID) that starts with an underscore?
The error message is quite straightforward.
It was more to confirm that the email address represents the username of the logged in user. I've been able to confirm that it does.
A fix for this has been merged and will be released in the coming weeks. Please feel free to re-test in mid-June to confirm the fix. Thanks for reporting! I'm going to close the issue, but you can still comment. Feel free to tag me if any issues.