Azure / Azure/azure-cli-extensions
az load test app-component add does not work for Microsoft.Sql/servers/databases
- Dominant language
- Python
- Stars
- 454
- Forks
- 1.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 64
Description
### Describe the bug
When trying to add a SQL database to a load test server-side components via the Azure CLI Load Test extension, the following error is emitted: `cli.azure.cli.core.azclierror: Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases`
When troubleshooting the issue, it looks like the problem is in this code:
[extensions/blob/8f63159b283c74c20d642b3c1c271090447bc2de/src/load/azext_load/data_plane/utils/validators.py#L155)](https://github.com/Azure/azure-cli-extensions/blob/8f63159b283c74c20d642b3c1c271090447bc2de/src/load/azext_load/data_plane/utils/validators.py#L155)
Specifically this line: `provider_name = "/".join(namespace.app_component_id.split("/")[6:8]).casefold()`
Since the full type of the database is not included in this split.
### Related command
`az load test app-component add --load-test-resource jarloadtestpoc --test-id 00000000-0000-0000-0000-000000000000 --app-component-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mobility-mpg-dev/providers/Microsoft.Sql/servers/jarpocsqlsrv/databases/jarpocsqldb" --app-component-type "Microsoft.Sql/servers/databases" --app-component-name jarpocsqldb --app-component-kind "v12.0,user" --debug`
### Errors
`cli.azure.cli.core.azclierror: Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases`
### Issue script & Debug output
az load test app-component add --load-test-resource jarloadtestpoc --test-id 00000000-0000-0000-0000-000000000000 --app-component-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mobility-mpg-dev/providers/Microsoft.Sql/servers/jarpocsqlsrv/databases/jarpocsqldb" --app-component-type "Microsoft.Sql/servers/databases" --app-component-name jarpocsqldb --app-component-kind "v12.0,user" --debug
cli.knack.cli: Command arguments: ['load', 'test', 'app-component', 'add', '--load-test-resource', 'jarloadtestpoc', '--test-id', '00000000-0000-0000-0000-000000000000', '--app-component-id', '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mobility-mpg-dev/providers/Microsoft.Sql/servers/jarpocsqlsrv/databases/jarpocsqldb', '--app-component-type', 'Microsoft.Sql/servers/databases', '--app-component-name', 'jarpocsqldb', '--app-component-kind', 'v12.0,user', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
Enable VT mode.
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 'load': ['azext_load']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: Total (0) 0.000 0 0
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: load 0.814 9 39 C:\Users\p1330505\.azure\cliextensions\load
cli.azure.cli.core: Total (1) 0.814 9 39
cli.azure.cli.core: Loaded 9 groups, 39 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : load test app-component add
cli.azure.cli.core: Command table: load test app-component add
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\p1330505\.azure\commands\2024-09-06.16-11-59.load_test_app-component_add.23092.log'.
az_command_data_logger: command args: load test app-component add --load-test-resource {} --test-id {} --app-component-id {} --app-component-type {} --app-component-name {} --app-component-kind {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x03C19C58>]
cli.knack.commands: Configured default 'mobility-mpg-dev' for arg resource_group_name
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x03C19C08>, .add_cache_arguments at 0x03C19CF8>, .update_breaking_change_info at 0x03C19D48>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x03C19CA8>]
az_command_data_logger: extension name: load
az_command_data_logger: extension version: 1.0.1
Command group 'load test app-component' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 654, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/invocation.py", line 113, in _validation
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 921, in _validate_arg_level
File "C:\Users\p1330505\.azure\cliextensions\load\azext_load\data_plane\utils\validators.py", line 158, in validate_app_component_type
raise InvalidArgumentValueError(
azure.cli.core.azclierror.InvalidArgumentValueError: Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases
cli.azure.cli.core.azclierror: Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases
az_command_data_logger: Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.508 seconds (init: 0.538, invoke: 0.970)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3963 in cache file under C:\Users\p1330505\.azure\telemetry\20240906161159419
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\p1330505\.azure C:\Users\p1330505\.azure\telemetry\20240906161159419"
telemetry.process: Return from creating process 4664
telemetry.main: Finish creating telemetry upload process.
### Expected behavior
The app component resource is added to the test.
### Environment Summary
azure-cli 2.64.0
core 2.64.0
telemetry 1.1.0
Extensions:
load 1.0.1
Dependencies:
msal 1.30.0
azure-mgmt-resource 23.1.1
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\p1330505\.azure\cliextensions'
Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 21:52:07) [MSC v.1937 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.