Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

"az mysql flexible-server import create "doesn't support subnet with multiple address prefix. #29446

Open kkyon opened 1 month ago

kkyon commented 1 month ago

Describe the bug

the command "az mysql flexible-server import create " didn't support subnet with multiple address prefix. if a subnet has a multiple address prefix ,it will cause the command error.

    "subnets": [
        {
            "name": "mysql",

            "properties": {
                "provisioningState": "Succeeded",
                "addressPrefixes": [
                    "10.5.0.0/24"
                ],
                "delegations": [],
                "privateEndpointNetworkPolicies": "Disabled",
                "privateLinkServiceNetworkPolicies": "Enabled"
            },
            "type": "Microsoft.Network/virtualNetworks/subnets"
        }

]

Related command

az mysql flexible-server import create

Errors

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback: az_command_data_logger: The command failed with an unexpected error. Here is the traceback: cli.azure.cli.core.azclierror: 'addressPrefix' 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 664, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/custom.py", line 570, in flexible_server_import_create File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/custom.py", line 1125, in flexible_server_provision_network_resource File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 126, in prepare_private_network File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 155, in process_private_network_with_id_input File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 213, in _create_vnet_subnet_delegation File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 226, in _create_subnet_delegation File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 226, in KeyError: 'addressPrefix' az_command_data_logger: 'addressPrefix' 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 664, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/custom.py", line 570, in flexible_server_import_create File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/custom.py", line 1125, in flexible_server_provision_network_resource File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 126, in prepare_private_network File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 155, in process_private_network_with_id_input File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 213, in _create_vnet_subnet_delegation File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 226, in _create_subnet_delegation File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/_network.py", line 226, in KeyError: 'addressPrefix' To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

cli.azure.cli.core.sdk.policies: Response content: cli.azure.cli.core.sdk.policies: { "name": "dbnet",

"type": "Microsoft.Network/virtualNetworks", "location": "northeurope", "tags": {}, "properties": { "provisioningState": "Succeeded",

"addressSpace": {
  "addressPrefixes": [
    "10.0.0.0/16"
  ]
},

"subnets": [
  {
    "name": "dbsubnet",

    "properties": {
      "provisioningState": "Succeeded",
      "addressPrefixes": [
        "10.0.1.0/24"
      ],

],
"virtualNetworkPeerings": [],
"enableDdosProtection": false

} }

Expected behavior

az mysql flexible-server import create

Environment Summary

{ "azure-cli": "2.58.0", "azure-cli-core": "2.58.0", "azure-cli-telemetry": "1.1.0", "extensions": { "account": "0.2.5", "arcdata": "1.5.13", "databricks": "0.10.2" } }

Additional context

No response

azure-client-tools-bot-prd[bot] commented 1 month ago

Hi @kkyon,

2.58.0 is not the latest Azure CLI(2.62.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

yonzhan commented 1 month ago

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

github-actions[bot] commented 1 month ago

Here are some similar issues that might help you. Please check if they can solve your problem.

microsoft-github-policy-service[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ambhatna, @savjani.

microsoft-github-policy-service[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ambhatna, @savjani.

kkyon commented 1 month ago

@ambhatna, @savjani. any update?

SudheeshGH commented 1 month ago

@kkyon , Can you please share the CLI command you are using

kkyon commented 1 month ago

@SudheeshGH I can't find the original full command. It can be reproduced.
the subnet show api will two different responses for addressPrefixe, the subnet created from portal. It will response with "addressPrefixes". It will cause the error for this issue. image

the subnet created from cli .it will response "addressPrefixe". "import cli" can work well.

image

SudheeshGH commented 1 month ago

It is caused by the new changes in networking side. We cannot support multiple address prefix for now. During MySQL flexible server creation, we will call to get subnet information. Previously, the response returned a string of addressPrefix. But for now, it always returns an array of addressPrefixes for the new subnets. But according to our test, only recently created subnets have this return. We plan to fix this issue in the next CLI release from MySQL side. This should work with the older subnet which are created before.

kkyon commented 1 month ago

Thanks for the feedback. @SudheeshGH