Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az load test app-component add does not work for Microsoft.Sql/servers/databases #7959

Open
BlackbirdWay opened this issue Sep 6, 2024 · 4 comments
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@BlackbirdWay
Copy link

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

@BlackbirdWay BlackbirdWay added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Sep 6, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 6, 2024

Thank you for opening this issue, we will look into it.

@microsoft-github-policy-service microsoft-github-policy-service bot added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Sep 6, 2024
@RodrigoDiasDeOliveira
Copy link

The error you are encountering, "Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases", is caused by a mismatch between the app-component-id and app-component-type parameters when trying to add a SQL database as a component for load testing via the Azure CLI Load Test extension.

Root Cause
The issue lies in the way the code handles the app-component-id. Specifically, the code attempts to extract the provider name from the app-component-id using the line:

python
Copiar código
provider_name = "/".join(namespace.app_component_id.split("/")[6:8]).casefold()
This split is extracting only part of the resource type, which results in an incorrect comparison later on, causing the mismatch.

For your specific case, it seems that the code is extracting only microsoft.sql/servers, while the actual full type is Microsoft.Sql/servers/databases.

Possible Solutions

  1. Modify the Command:
    Try modifying the command by changing the app-component-type to match the extracted type microsoft.sql/servers. Although this might not be the complete resource type, it could bypass the validation step:

bash

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" --app-component-name jarpocsqldb --app-component-kind "v12.0,user" --debug
2. Fix in the Extension Code:
If modifying the command doesn't work or if you have control over the extension code, you might want to modify the validators.py file to handle the full resource type.

You can adjust the provider_name extraction logic to capture the full path:

python

provider_name = "/".join(namespace.app_component_id.split("/")[6:9]).casefold()
This will include the databases part in the provider_name.

  1. Create an Issue on GitHub:
    If you don't have control over the extension's code, consider reporting this issue on the Azure CLI GitHub repository or the repository for the specific extension. This way, the maintainers can update the code to handle the full resource path correctly.

Summary
Try modifying the command to use microsoft.sql/servers as the app-component-type.
If you can edit the extension code, update the extraction logic to include the full path.
Report the issue on GitHub if you cannot resolve it locally.

I wsih i could help, regards

@yonzhan yonzhan added Service Attention This issue is responsible by Azure service team. and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Sep 6, 2024
@BlackbirdWay
Copy link
Author

The error you are encountering, "Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases", is caused by a mismatch between the app-component-id and app-component-type parameters when trying to add a SQL database as a component for load testing via the Azure CLI Load Test extension.

Root Cause The issue lies in the way the code handles the app-component-id. Specifically, the code attempts to extract the provider name from the app-component-id using the line:

python Copiar código provider_name = "/".join(namespace.app_component_id.split("/")[6:8]).casefold() This split is extracting only part of the resource type, which results in an incorrect comparison later on, causing the mismatch.

For your specific case, it seems that the code is extracting only microsoft.sql/servers, while the actual full type is Microsoft.Sql/servers/databases.

Possible Solutions

  1. Modify the Command:
    Try modifying the command by changing the app-component-type to match the extracted type microsoft.sql/servers. Although this might not be the complete resource type, it could bypass the validation step:

bash

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" --app-component-name jarpocsqldb --app-component-kind "v12.0,user" --debug 2. Fix in the Extension Code: If modifying the command doesn't work or if you have control over the extension code, you might want to modify the validators.py file to handle the full resource type.

You can adjust the provider_name extraction logic to capture the full path:

python

provider_name = "/".join(namespace.app_component_id.split("/")[6:9]).casefold() This will include the databases part in the provider_name.

  1. Create an Issue on GitHub:
    If you don't have control over the extension's code, consider reporting this issue on the Azure CLI GitHub repository or the repository for the specific extension. This way, the maintainers can update the code to handle the full resource path correctly.

Summary Try modifying the command to use microsoft.sql/servers as the app-component-type. If you can edit the extension code, update the extraction logic to include the full path. Report the issue on GitHub if you cannot resolve it locally.

I wsih i could help, regards

Thanks @RodrigoDiasDeOliveira, but I couldn't get this working with your 3 options because:

  1. When I modified the type for the SQL database to --app-component-type "microsoft.sql/servers", it did not show up on Server-side metrics area of the page once a test was run.
  2. The code is run via Azure DevOps pipeline using custom agent that I do not have permissions to modify.
  3. I thought that's what I was doing here :)

@RodrigoDiasDeOliveira
Copy link

sorry about the gap, i was very busy in the work, so i was searching for an logical anwser ..and how about this type of alternative:
It seems like you're encountering a bug with the Azure CLI Load Test extension related to the mismatch between the app-component-id and app-component-type parameters when trying to add a SQL database. Here’s a breakdown of the situation and some potential steps to address it:

Problem Summary
When you execute the command to add a SQL database as an app component for load testing, you receive an error indicating a type mismatch. The error message states:

python
Copiar código
cli.azure.cli.core.azclierror: Type of app-component-id and app-component-type mismatch: microsoft.sql/servers vs Microsoft.Sql/servers/databases
This indicates that the app component ID and type do not align correctly, causing the command to fail.

I think the Root Cause is the underlying issue appears to stem from the extraction of the provider name from the app-component-id within the code. Specifically, the problematic line in the validators.py file is:

python
provider_name = "/".join(namespace.app_component_id.split("/")[6:8]).casefold()
This code extracts only part of the resource type (microsoft.sql/servers), which does not match the complete type of the resource (Microsoft.Sql/servers/databases).

Possible Solutions
Modify the Command: Change the app-component-type in your command to match the extracted type:

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" --app-component-name jarpocsqldb --app-component-kind "v12.0,user" --debug
Note that this might bypass the validation, but it’s not a long-term fix. you will have to fix in the Extension Code: If you have access to the extension code, consider modifying the validators.py file to adjust the extraction logic to capture the full resource type:

python
provider_name = "/".join(namespace.app_component_id.split("/")[6:9]).casefold()
This change would allow the comparison to work correctly by including the full path.

The mismatch error is due to how the app-component-id is processed in the code. You can either adjust your command temporarily, modify the extension if possible, or report the bug for a more permanent fix.
i really hope it an helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

3 participants