Azure / azure-cli

Azure Command-Line Interface
MIT License
3.98k stars 2.96k forks source link

Failure of `az containerapp connection create postgres` with `'Namespace' object has no attribute 'opt_out_list'` #28865

Closed parisk closed 4 months ago

parisk commented 4 months ago

Describe the bug

I am trying to create a connection for an Azure Container App, through the Azure UI. I am clicking on "Create on Cloud Shell" and it fails.

Related command

az extension add --name containerapp
az extension add --name serviceconnector-passwordless --upgrade
az containerapp connection create postgres --connection ... --source-id /subscriptions/.../providers/Microsoft.App/containerApps/web --target-id /subscriptions/.../providers/Microsoft.DBforPostgreSQL/servers/.../databases/postgres --client-type django --system-identity -c web

Errors

'Namespace' object has no attribute 'opt_out_list'

Issue script & Debug output

cli.knack.cli: Command arguments: ['containerapp', 'connection', 'create', 'postgres', '--connection', 'TRUNCATED', '--source-id', '/subscriptions/TRUNCATED/resourceGroups/TRUNCATED/providers/Microsoft.App/containerApps/web', '--target-id', '/subscriptions/TRUNCATED/resourceGroups/TRUNCATED/providers/Microsoft.DBforPostgreSQL/servers/TRUNCATED/databases/postgres', '--client-type', 'django', '--system-identity', '-c', 'web', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f13310d61f0>, <function OutputProducer.on_global_arguments at 0x7f1330ff0d30>, <function CLIQuery.on_global_arguments at 0x7f1330f88310>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'containerapp': ['azext_containerapp', 'azure.cli.command_modules.containerapp', 'azure.cli.command_modules.serviceconnector', 'azext_serviceconnector_passwordless']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: containerapp              0.469        36       115
cli.azure.cli.core: serviceconnector          0.136        20       299
cli.azure.cli.core: Total (2)                 0.605        56       414
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: ai-examples               0.123         1         1  /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: containerapp              0.021        35       102  /home/paris/.azure/cliextensions/containerapp
cli.azure.cli.core: serviceconnector-passwordless      0.121        14        20  /home/paris/.azure/cliextensions/serviceconnector-passwordless
cli.azure.cli.core: Total (3)                 0.265        50       123  
cli.azure.cli.core: Loaded 79 groups, 488 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : containerapp connection create postgres
cli.azure.cli.core: Command table: containerapp connection create postgres
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f1330436790>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/paris/.azure/commands/2024-05-01.13-55-06.containerapp_connection_create_postgres.977.log'.
az_command_data_logger: command args: containerapp connection create postgres --connection {} --source-id {} --target-id {} --client-type {} --system-identity -c {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f13303de3a0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f13304063a0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f13303a9280>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f1330ff0dc0>, <function CLIQuery.handle_query_parameter at 0x7f1330f883a0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f13303a91f0>]
az_command_data_logger: extension name: serviceconnector-passwordless
az_command_data_logger: extension version: 1.0.3
cli.azure.cli.core.commands: The behavior of this command has been altered by the following extension: serviceconnector-passwordless
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/invocation.py", line 113, in _validation
    self._validate_arg_level(parsed_ns)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 898, in _validate_arg_level
    validator(**self._build_kwargs(validator, ns))
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 886, in validate_params
    _validate_and_apply(validate_create_params, apply_create_params)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 868, in _validate_and_apply
    missing_args = validate(cmd, namespace)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 633, in validate_create_params
    if not validate_opt_out_auth_and_config(namespace):
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/serviceconnector/_validators.py", line 449, in validate_opt_out_auth_and_config
    opt_out_list = namespace.opt_out_list
AttributeError: 'Namespace' object has no attribute 'opt_out_list'

cli.azure.cli.core.azclierror: 'Namespace' object has no attribute 'opt_out_list'
az_command_data_logger: 'Namespace' object has no attribute 'opt_out_list'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f13304369d0>]
az_command_data_logger: exit code: 2
cli.__main__: Command ran in 1.182 seconds (init: 0.240, invoke: 0.942)
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 4019 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/__init__.py /home/paris/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

I would expect it to pretty much create the connection and extract environment variables that can be used from Django

Environment Summary

paris [ ~ ]$ az --version
azure-cli                         2.60.0

core                              2.60.0
telemetry                          1.1.0

Extensions:
ai-examples                        0.2.5
containerapp                      0.3.50
ml                                2.25.1
serviceconnector-passwordless               1.0.3
ssh                                2.0.3

Dependencies:
msal                              1.28.0
azure-mgmt-resource             23.1.0b2

Python location '/usr/bin/python3.9'
Extensions directory '/home/paris/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.19 (main, Mar 28 2024, 18:56:59) 
[GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

I am suspecting it broke in 2.60.0. Might be related to https://github.com/Azure/azure-cli/pull/28079.

yonzhan commented 4 months ago

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

kayfilipp commented 4 months ago

Could we patch this by running any pip update statements through cloudshell?

stevehawken commented 4 months ago

Same issue setting up a connection for .net / azure sql web app. Running this locally with the CLI instead of cloud shell worked.

kayfilipp commented 4 months ago

Interesting - I tried running in CLI locally and still ran into the same issue.


az functionapp connection create sql --connection sql_611f1 --source-id "/subscriptions/.../resourceGroups/test-az-rg/providers/Microsoft.Web/sites/p10-test-az-func" --target-id "/subscriptions/.../resourceGroups/p10-dev-rg/providers/Microsoft.Sql/servers/p10-dev-sqlserver/databases/..." --client-type python --system-identity

az extension add --name serviceconnector-passwordless --upgrade  

az functionapp connection create sql --connection sql_611f1 --source-id "/subscriptions/.../resourceGroups/test-az-rg/providers/Microsoft.Web/sites/..." --target-id "/subscriptions/.../resourceGroups/p10-dev-rg/providers/Microsoft.Sql/servers/.../databases/FirmInsights" --client-type python --system-identity                                                        
houk-ms commented 4 months ago

@xfz11, please take a look

nevenc commented 4 months ago

I am having similar issues on az spring connection list ... command as well. I was able to create a connection, but cannot list or show - also on az CLI 2.60.0