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)
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 [<function CLILogging.on_global_arguments at 0x01A3DA28>, <function OutputProducer.on_global_arguments at 0x01B67B18>, <function CLIQuery.on_global_arguments at 0x01D8B8E8>]
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 [<function AzCliLogging.init_command_file_logging at 0x03BC0488>]
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 [<function register_global_subscription_argument..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 [<function register_ids_argument..add_ids_arguments at 0x03C19C08>, <function register_cache_arguments..add_cache_arguments at 0x03C19CF8>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x03C19D48>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x01B67B68>, <function CLIQuery.handle_query_parameter at 0x01D8B938>, <function register_ids_argument..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 [<function AzCliLogging.deinit_cmd_metadata_logging at 0x03BC05C8>]
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