Skip to content

[DO NOT MERGE] [Server] Self-service deleted server restore#31360

Open
pjpatel12 wants to merge 14 commits intoAzure:devfrom
pjpatel12:self-service-deleted-server-restore
Open

[DO NOT MERGE] [Server] Self-service deleted server restore#31360
pjpatel12 wants to merge 14 commits intoAzure:devfrom
pjpatel12:self-service-deleted-server-restore

Conversation

@pjpatel12
Copy link
Copy Markdown

Related command
az sql server create, az sql server update, az sql server restore

Description
Adds ability to set/update logical server retention days as well as passing create mode on server create to support logical server restore.

Testing Guide
az sql server create --create-mode Restore, az sql server update --retention-days 7

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 25, 2025

❌AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
❌monitor
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_metric_alert_for_sql_database_scope self = <azure.cli.testsdk.base.ExecutionResult object at 0x7fafb7935100>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7fafb7c0c080>
command = 'sql server create -l westus -g cli_test_metric_alert_v1_2000001 -n clitestservermatricalertA000002 -u admin123 -p SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/preparers.py:50: in preparer_wrapper
    fn(test_class_instance, **kwargs)
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/preparers.py:39: in preparer_wrapper
    parameter_update = self.create_resource(
src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:61: in create_resource
    execute(DummyCli(), template.format(self.location, group, name, self.admin_user, self.admin_password))
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
 
 
 
 
                               _ 

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7fafb775d5e0>
resource_group_name = 'cli_test_metric_alert_v1_2000001'
server_name = 'clitestservermatricalertA000002', minimal_tls_version = None
assign_identity = False, no_wait = False, enable_public_network = None
restrict_outbound_network_access = None, key_id = None
federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7fafbb48bc50>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py:267
❌3.9
Type Test Case Error Message Line
Failed test_metric_alert_for_sql_database_scope self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f89753057c0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f8975304f70>
command = 'sql server create -l westus -g cli_test_metric_alert_v1_2000001 -n clitestservermatricalertA000002 -u admin123 -p SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.9/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/preparers.py:50: in preparer_wrapper
    fn(test_class_instance, **kwargs)
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/preparers.py:39: in preparer_wrapper
    parameter_update = self.create_resource(
src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:61: in create_resource
    execute(DummyCli(), template.format(self.location, group, name, self.admin_user, self.admin_password))
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.9/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
 
 
 
 
                               _ 

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f8975052160>
resource_group_name = 'cli_test_metric_alert_v1_2000001'
server_name = 'clitestservermatricalertA000002', minimal_tls_version = None
assign_identity = False, no_wait = False, enable_public_network = None
restrict_outbound_network_access = None, key_id = None
federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f8975338fd0>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/monitor/tests/latest/test_monitor_metric_alert_scenarios.py:267
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
❌network
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_private_endpoint_connection_sql_server self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f5ef4ddc6b0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f5ef5417500>
command = 'sql server create -g test_private_endpoint_connection_sql_server000001 -n cli-test-resource-000006 --admin-user admin123 --admin-password SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.network.tests.latest.test_private_endpoint_commands.NetworkPrivateLinkScenarioTest testMethod=test_private_endpoint_connection_sql_server>
resource_group = 'test_private_endpoint_connection_sql_server000001'

    @ResourceGroupPreparer(name_prefix="test_private_endpoint_connection_sql_server", location="westus")
    def test_private_endpoint_connection_sql_server(self, resource_group):
        self.kwargs.update({
            'rg': resource_group,
            # config begin
            'cmd': 'sql server',
            'list_num': 1,
            'type': 'Microsoft.Sql/servers',
            'extra_create': '--admin-user admin123 --admin-password SecretPassword123',
        })
    
>       test_private_endpoint(self, approve=False, rejected=False)

src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:2551: 
 
 
                                      
src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:2427: in test_private_endpoint
    self.cmd('{cmd} create -g {rg} {create_name} {resource} {extra_create}')
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
 
 
                                 _ 

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f5ef4431130>
resource_group_name = 'test_private_endpoint_connection_sql_server000001'
server_name = 'cli-test-resource-000006', minimal_tls_version = None
assign_identity = False, no_wait = False, enable_public_network = None
restrict_outbound_network_access = None, key_id = None
federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f5ef46a7620>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:2539
❌3.9
Type Test Case Error Message Line
Failed test_private_endpoint_connection_sql_server self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f594715aca0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f594771d040>
command = 'sql server create -g test_private_endpoint_connection_sql_server000001 -n cli-test-resource-000006 --admin-user admin123 --admin-password SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.9/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.network.tests.latest.test_private_endpoint_commands.NetworkPrivateLinkScenarioTest testMethod=test_private_endpoint_connection_sql_server>
resource_group = 'test_private_endpoint_connection_sql_server000001'

    @ResourceGroupPreparer(name_prefix="test_private_endpoint_connection_sql_server", location="westus")
    def test_private_endpoint_connection_sql_server(self, resource_group):
        self.kwargs.update({
            'rg': resource_group,
            # config begin
            'cmd': 'sql server',
            'list_num': 1,
            'type': 'Microsoft.Sql/servers',
            'extra_create': '--admin-user admin123 --admin-password SecretPassword123',
        })
    
>       test_private_endpoint(self, approve=False, rejected=False)

src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:2551: 
 
 
                                      
src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:2427: in test_private_endpoint
    self.cmd('{cmd} create -g {rg} {create_name} {resource} {extra_create}')
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.9/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
 
 
                                 _ 

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f59467ab1c0>
resource_group_name = 'test_private_endpoint_connection_sql_server000001'
server_name = 'cli-test-resource-000006', minimal_tls_version = None
assign_identity = False, no_wait = False, enable_public_network = None
restrict_outbound_network_access = None, key_id = None
federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f5946803f40>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:2539
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
❌sql
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_sql_refresh_external_governance_status self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f5c458fade0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f5c45262720>
command = 'sql server create -l eastus2euap -g clitest.rg000001 -n clitestserver000002 -u admin123 -p SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.sql.tests.latest.test_sql_commands.SqlServerPreparer object at 0x7f5c47d4f0b0>
name = 'clitestserver000002'
kwargs = {'resource_group': 'clitest.rg000001', 'resource_group_location': 'eastus2euap'}
group = 'clitest.rg000001'
template = 'az sql server create -l {} -g {} -n {} -u {} -p {}'

    def create_resource(self, name, **kwargs):
        group = self.get_resource_group(**kwargs)
        template = 'az sql server create -l {} -g {} -n {} -u {} -p {}'
>       execute(DummyCli(), template.format(self.location, group, name, self.admin_user, self.admin_password))

src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:61: 
 
 
                                      
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
 
                                   

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f5c44df1970>
resource_group_name = 'clitest.rg000001', server_name = 'clitestserver000002'
minimal_tls_version = None, assign_identity = False, no_wait = False
enable_public_network = None, restrict_outbound_network_access = None
key_id = None, federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f5c45989d00>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:176
Failed test_sql_server_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f5c451c2c60>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f5c47b60aa0>
command = 'sql server create -g clitest.rg000001 --name clitestserver000003 --admin-user admin123 --admin-password SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.sql.tests.latest.test_sql_commands.SqlServerMgmtScenarioTest testMethod=test_sql_server_mgmt>
resource_group_1 = 'clitest.rg000001', resource_group_2 = 'clitest.rg000002'
resource_group_location = 'westeurope'

    @ResourceGroupPreparer(parameter_name='resource_group_1', location='westeurope')
    @ResourceGroupPreparer(parameter_name='resource_group_2', location='westeurope')
    def test_sql_server_mgmt(self, resource_group_1, resource_group_2, resource_group_location):
        server_name_1 = self.create_random_name(server_name_prefix, server_name_max_length)
        server_name_2 = self.create_random_name(server_name_prefix, server_name_max_length)
        server_name_3 = self.create_random_name(server_name_prefix, server_name_max_length)
    
        admin_login = 'admin123'
        admin_passwords = ['SecretPassword123', 'SecretPassword456', 'SecretPassword789']
        federated_client_id_1 = '748eaea0-6dbc-4be9-a50b-6a2d3dad00d4'
        federated_client_id_2 = '17deee33-9da7-40ce-a33c-8a96f2f8f07d'
        federated_client_id_3 = '00000000-0000-0000-0000-000000000000'
    
        # test create sql server with minimal required parameters
>       server_1 = self.cmd('sql server create -g {} --name {} '
                            '--admin-user {} --admin-password {}'
                            .format(resource_group_1, server_name_1, admin_login, admin_passwords[0]),
                            checks=[
                                JMESPathCheck('name', server_name_1),
                                JMESPathCheck('location', resource_group_location),
                                JMESPathCheck('resourceGroup', resource_group_1),
                                JMESPathCheck('administratorLogin', admin_login),
                                JMESPathCheck('identity', None)]).get_output_in_json()

src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:202: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
                                   _ 

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f5c44a8cad0>
resource_group_name = 'clitest.rg000001', server_name = 'clitestserver000003'
minimal_tls_version = None, assign_identity = False, no_wait = False
enable_public_network = None, restrict_outbound_network_access = None
key_id = None, federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f5c449e5880>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:187
Failed test_sql_server_public_network_access_create_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:278
Failed test_sql_server_public_network_access_update_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:331
Failed test_sql_server_retention_days_create_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f5c451015e0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f5c47a0c470>
command = 'group create --location westeurope --name clitest.rgkw6jzpsulcmjuzeoszh7aa66h5ist2inpceorpqbumlwylekjoyua5px3kl52votf...ct=azurecli cause=automation test date=2025-05-09T03:51:02Z test=test_sql_server_retention_days_create_mgmt module=sql'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = CLIError("Please run 'az login' to setup account."), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception CLIError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/preparers.py:39: in preparer_wrapper
    parameter_update = self.create_resource(
src/azure-cli-testsdk/azure/cli/testsdk/preparers.py:99: in create_resource
    self.live_only_execute(self.cli_ctx, template.format(self.location, name))
src/azure-cli-testsdk/azure/cli/testsdk/preparers.py:39: in live_only_execute
    return self.raw_execute(cli_ctx, command, expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
src/azure-cli/azure/cli/command_modules/resource/custom.py:1647: in create_resource_group
    rcf = resource_client_factory(cmd.cli_ctx)
src/azure-cli/azure/cli/command_modules/resource/client_factory.py:10: in resource_client_factory
    return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
src/azure-cli-core/azure/cli/core/commands/client_factory.py:83: in get_mgmt_service_client
    client, 
 = get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
src/azure-cli-core/azure/cli/core/commands/client_factory.py:231: in get_mgmt_service_client
    credential, subscription_id, 
 = profile.get_login_credentials(
src/azure-cli-core/azure/cli/core/profile.py:362: in get_login_credentials
    account = self.get_subscription(subscription_id)
 
 
 
 
 
 
 
 
 
 
 
 
                           _ 

self = <azure.cli.core._profile.Profile object at 0x7f5c4486e4b0>
subscription = None

    def get_subscription(self, subscription=None):  # take id or name
        subscriptions = self.load_cached_subscriptions()
        if not subscriptions:
>           raise CLIError(_AZ_LOGIN_MESSAGE)
E           knack.util.CLIError: Please run 'az login' to setup account.

src/azure-cli-core/azure/cli/core/_profile.py:611: CLIError
azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:389
Failed test_sql_server_retention_days_update_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:408
Failed test_sql_firewall_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:435
Failed test_sql_ipv6_firewall_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:547
Failed test_sql_db_ledger The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:898
Failed test_sql_db_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:669
Failed test_sql_db_preferred_enclave_type The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:979
Failed test_sql_db_read_replica_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:857
Failed test_sql_db_vcore_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:773
Failed test_sql_db_serverless_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1058
Failed test_sql_db_free_params The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1145
Failed test_sql_db_operation_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1182
Failed test_sql_db_forward_migration_manual_cutover The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1216
Failed test_sql_server_connection_policy The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1513
Failed test_aad_admin The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1529
Failed test_aadonly The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1576
Failed test_sql_db_copy The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1595
Failed test_sql_db_copy_with_perdb_cmk The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1671
Failed test_sql_db_restore The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1762
Failed test_sql_db_restore_deleted The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1829
Failed test_sql_db_security_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1902
Failed test_sql_server_security_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2160
Failed test_sql_server_advanced_threat_protection The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2360
Failed test_sql_db_advanced_threat_protection The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2406
Failed test_sql_server_ms_support_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2583
Failed test_sql_dw_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2758
Failed test_sql_server_dns_alias_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2867
Failed test_sql_db_replica_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2990
Failed test_sql_elastic_pools_preferred_enclave_type_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3660
Failed test_sql_elastic_pools_vcore_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3458
Failed test_sql_elastic_pool_operation_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3768
Failed test_sql_db_import_export_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3980
Failed test_sql_tde The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4199
Failed test_sql_server_identity The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4337
Failed test_sql_vnet_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4390
Failed test_sql_zone_resilient_copy_hyperscale_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4694
Failed test_sql_zone_resilient_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4486
Failed test_sql_zone_resilient_pool The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4587
Failed test_sql_zone_resilient_replica_hyperscale_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4774
Failed test_sql_zone_resilient_restore_hyperscale_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4888
Failed test_sql_failover_group_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:6593
Failed test_sql_server_minimal_tls_version The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:7100
Failed test_sql_ledger The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:7235
❌3.9
Type Test Case Error Message Line
Failed test_sql_refresh_external_governance_status self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f643926bd60>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f64392643d0>
command = 'sql server create -l eastus2euap -g clitest.rg000001 -n clitestserver000002 -u admin123 -p SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.9/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.sql.tests.latest.test_sql_commands.SqlServerPreparer object at 0x7f643bf83c70>
name = 'clitestserver000002'
kwargs = {'resource_group': 'clitest.rg000001', 'resource_group_location': 'eastus2euap'}
group = 'clitest.rg000001'
template = 'az sql server create -l {} -g {} -n {} -u {} -p {}'

    def create_resource(self, name, **kwargs):
        group = self.get_resource_group(**kwargs)
        template = 'az sql server create -l {} -g {} -n {} -u {} -p {}'
>       execute(DummyCli(), template.format(self.location, group, name, self.admin_user, self.admin_password))

src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:61: 
 
 
                                      
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.9/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
 
                                   

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f6438e63640>
resource_group_name = 'clitest.rg000001', server_name = 'clitestserver000002'
minimal_tls_version = None, assign_identity = False, no_wait = False
enable_public_network = None, restrict_outbound_network_access = None
key_id = None, federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f6438e63070>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:176
Failed test_sql_server_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f643922fc40>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f643bde3550>
command = 'sql server create -g clitest.rg000001 --name clitestserver000003 --admin-user admin123 --admin-password SecretPassword123'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.9/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = KeyError('create_mode'), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception KeyError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.sql.tests.latest.test_sql_commands.SqlServerMgmtScenarioTest testMethod=test_sql_server_mgmt>
resource_group_1 = 'clitest.rg000001', resource_group_2 = 'clitest.rg000002'
resource_group_location = 'westeurope'

    @ResourceGroupPreparer(parameter_name='resource_group_1', location='westeurope')
    @ResourceGroupPreparer(parameter_name='resource_group_2', location='westeurope')
    def test_sql_server_mgmt(self, resource_group_1, resource_group_2, resource_group_location):
        server_name_1 = self.create_random_name(server_name_prefix, server_name_max_length)
        server_name_2 = self.create_random_name(server_name_prefix, server_name_max_length)
        server_name_3 = self.create_random_name(server_name_prefix, server_name_max_length)
    
        admin_login = 'admin123'
        admin_passwords = ['SecretPassword123', 'SecretPassword456', 'SecretPassword789']
        federated_client_id_1 = '748eaea0-6dbc-4be9-a50b-6a2d3dad00d4'
        federated_client_id_2 = '17deee33-9da7-40ce-a33c-8a96f2f8f07d'
        federated_client_id_3 = '00000000-0000-0000-0000-000000000000'
    
        # test create sql server with minimal required parameters
>       server_1 = self.cmd('sql server create -g {} --name {} '
                            '--admin-user {} --admin-password {}'
                            .format(resource_group_1, server_name_1, admin_login, admin_passwords[0]),
                            checks=[
                                JMESPathCheck('name', server_name_1),
                                JMESPathCheck('location', resource_group_location),
                                JMESPathCheck('resourceGroup', resource_group_1),
                                JMESPathCheck('administratorLogin', admin_login),
                                JMESPathCheck('identity', None)]).get_output_in_json()

src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:202: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.9/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
 
 
 
 
                                   _ 

client = <azure.mgmt.sql.operations._servers_operations.ServersOperations object at 0x7f6438a934c0>
resource_group_name = 'clitest.rg000001', server_name = 'clitestserver000003'
minimal_tls_version = None, assign_identity = False, no_wait = False
enable_public_network = None, restrict_outbound_network_access = None
key_id = None, federated_client_id = None, user_assigned_identity_id = None
primary_user_assigned_identity_id = None, identity_type = None
enable_ad_only_auth = False, external_admin_principal_type = None
external_admin_sid = None, external_admin_name = None, create_mode = None
retention_days = None
kwargs = {'administrator_login': 'admin123', 'administrator_login_password': 'SecretPassword123', 'administrators': <azure.mgmt.sql.models._models_py3.ServerExternalAdministrator object at 0x7f6438c79d30>, 'federated_client_id': None, ...}
ad_only = None, tenant_id = None

    def server_create(
            client,
            resource_group_name,
            server_name,
            minimal_tls_version=None,
            assign_identity=False,
            no_wait=False,
            enable_public_network=None,
            restrict_outbound_network_access=None,
            key_id=None,
            federated_client_id=None,
            user_assigned_identity_id=None,
            primary_user_assigned_identity_id=None,
            identity_type=None,
            enable_ad_only_auth=False,
            external_admin_principal_type=None,
            external_admin_sid=None,
            external_admin_name=None,
            create_mode=None,
            retention_days=None,
            **kwargs):
        '''
        Creates a server.
        '''
    
        if create_mode:
            kwargs['create_mode'] = create_mode
    
        if assign_identity:
            kwargs['identity'] = _get_identity_object_from_type(True, identity_type, user_assigned_identity_id, None)
        else:
            kwargs['identity'] = _get_identity_object_from_type(False, identity_type, user_assigned_identity_id, None)
    
        if enable_public_network is not None:
            kwargs['public_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if enable_public_network
                else ServerNetworkAccessFlag.DISABLED)
    
        if restrict_outbound_network_access is not None:
            kwargs['restrict_outbound_network_access'] = (
                ServerNetworkAccessFlag.ENABLED if restrict_outbound_network_access
                else ServerNetworkAccessFlag.DISABLED)
    
        if retention_days is not None:
            kwargs['soft_delete_retention_days'] = retention_days
    
        if minimal_tls_version is not None:
            kwargs['minimal_tls_version'] = minimal_tls_version
        else:
            kwargs['minimal_tls_version'] = SqlServerMinimalTlsVersionType.tls_1_2
    
        kwargs['key_id'] = key_id
        kwargs['federated_client_id'] = federated_client_id
    
        kwargs['primary_user_assigned_identity_id'] = primary_user_assigned_identity_id
    
        ad_only = None
        if enable_ad_only_auth:
            ad_only = True
    
        tenant_id = None
        if external_admin_name is not None:
            tenant_id = _get_tenant_id()
    
        kwargs['administrators'] = ServerExternalAdministrator(
            principal_type=external_admin_principal_type,
            login=external_admin_name,
            sid=external_admin_sid,
            azure_ad_only_authentication=ad_only,
            tenant_id=tenant_id)
    
>       print(kwargs['create_mode'])
E       KeyError: 'create_mode'

src/azure-cli/azure/cli/command_modules/sql/custom.py:4200: KeyError
azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:187
Failed test_sql_server_public_network_access_create_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:278
Failed test_sql_server_public_network_access_update_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:331
Failed test_sql_server_retention_days_create_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f6441802df0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f643bf4ceb0>
command = 'group create --location westeurope --name clitest.rgqihruk2v462txtvhwcjtmjfhuwdhcz7qf7chbmy2qxfbrtjham2nijxolctvwxo4y...ct=azurecli cause=automation test date=2025-05-09T03:51:55Z test=test_sql_server_retention_days_create_mgmt module=sql'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.9/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:129: in exception_handler
    return handle_exception(ex)
                                        

ex = CLIError("Please run 'az login' to setup account."), args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception CLIError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:
src/azure-cli-testsdk/azure/cli/testsdk/scenario_tests/preparers.py:39: in preparer_wrapper
    parameter_update = self.create_resource(
src/azure-cli-testsdk/azure/cli/testsdk/preparers.py:99: in create_resource
    self.live_only_execute(self.cli_ctx, template.format(self.location, name))
src/azure-cli-testsdk/azure/cli/testsdk/preparers.py:39: in live_only_execute
    return self.raw_execute(cli_ctx, command, expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.9/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:666: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:734: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:703: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:336: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:120: in handler
    return op(**command_args)
src/azure-cli/azure/cli/command_modules/resource/custom.py:1647: in create_resource_group
    rcf = resource_client_factory(cmd.cli_ctx)
src/azure-cli/azure/cli/command_modules/resource/client_factory.py:10: in resource_client_factory
    return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
src/azure-cli-core/azure/cli/core/commands/client_factory.py:83: in get_mgmt_service_client
    client, 
 = get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
src/azure-cli-core/azure/cli/core/commands/client_factory.py:231: in get_mgmt_service_client
    credential, subscription_id, 
 = profile.get_login_credentials(
src/azure-cli-core/azure/cli/core/profile.py:362: in get_login_credentials
    account = self.get_subscription(subscription_id)
 
 
 
 
 
 
 
 
 
 
 
 
                           _ 

self = <azure.cli.core._profile.Profile object at 0x7f6438aa9400>
subscription = None

    def get_subscription(self, subscription=None):  # take id or name
        subscriptions = self.load_cached_subscriptions()
        if not subscriptions:
>           raise CLIError(_AZ_LOGIN_MESSAGE)
E           knack.util.CLIError: Please run 'az login' to setup account.

src/azure-cli-core/azure/cli/core/_profile.py:611: CLIError
azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:389
Failed test_sql_server_retention_days_update_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:408
Failed test_sql_firewall_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:435
Failed test_sql_ipv6_firewall_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:547
Failed test_sql_db_ledger The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:898
Failed test_sql_db_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:669
Failed test_sql_db_preferred_enclave_type The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:979
Failed test_sql_db_read_replica_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:857
Failed test_sql_db_vcore_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:773
Failed test_sql_db_serverless_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1058
Failed test_sql_db_free_params The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1145
Failed test_sql_db_operation_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1182
Failed test_sql_db_forward_migration_manual_cutover The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1216
Failed test_sql_server_connection_policy The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1513
Failed test_aad_admin The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1529
Failed test_aadonly The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1576
Failed test_sql_db_copy The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1595
Failed test_sql_db_copy_with_perdb_cmk The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1671
Failed test_sql_db_restore The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1762
Failed test_sql_db_restore_deleted The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1829
Failed test_sql_db_security_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:1902
Failed test_sql_server_security_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2160
Failed test_sql_server_advanced_threat_protection The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2360
Failed test_sql_db_advanced_threat_protection The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2406
Failed test_sql_server_ms_support_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2583
Failed test_sql_dw_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2758
Failed test_sql_server_dns_alias_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2867
Failed test_sql_db_replica_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:2990
Failed test_sql_elastic_pools_preferred_enclave_type_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3660
Failed test_sql_elastic_pools_vcore_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3458
Failed test_sql_elastic_pool_operation_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3768
Failed test_sql_db_import_export_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:3980
Failed test_sql_tde The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4199
Failed test_sql_server_identity The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4337
Failed test_sql_vnet_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4390
Failed test_sql_zone_resilient_copy_hyperscale_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4694
Failed test_sql_zone_resilient_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4486
Failed test_sql_zone_resilient_pool The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4587
Failed test_sql_zone_resilient_replica_hyperscale_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4774
Failed test_sql_zone_resilient_restore_hyperscale_database The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:4888
Failed test_sql_failover_group_mgmt The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:6593
Failed test_sql_server_minimal_tls_version The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:7100
Failed test_sql_ledger The error message is too long, please check the pipeline log for details. azure/cli/command_modules/sql/tests/latest/test_sql_commands.py:7235
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 25, 2025

❌AzureCLI-BreakingChangeTest
❌sql
rule cmd_name rule_message suggest_message
1010 - ParaPropUpdate sql server audit-policy update cmd sql server audit-policy update update parameter retention_days: updated property options from ['--retention-days'] to ['--rd', '--retention-days-soft-delete'] please change property options from ['--rd', '--retention-days-soft-delete'] to ['--retention-days'] for parameter retention_days of cmd sql server audit-policy update
⚠️ 1006 - ParaAdd sql server create cmd sql server create added parameter create_mode
⚠️ 1006 - ParaAdd sql server create cmd sql server create added parameter retention_days
⚠️ 1001 - CmdAdd sql server restore cmd sql server restore added
⚠️ 1006 - ParaAdd sql server update cmd sql server update added parameter retention_days

Please submit your Breaking Change Pre-announcement ASAP if you haven't already. Please note:

  • Breaking changes can only be merged during the designated breaking change window
  • A pre-announcement must be released at least one month in advance

For more details on how to introduce breaking changes, refer to the documentation: azure-cli/doc/how_to_introduce_breaking_changes.md

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 25, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@pjpatel12 pjpatel12 changed the title [Server] Self-service deleted server restore [DO NOT MERGE] [Server] Self-service deleted server restore May 13, 2025
@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants