|
44 | 44 | get_secret_type_for_update |
45 | 45 | ) |
46 | 46 | from ._credential_free import is_passwordless_command |
47 | | -# pylint: disable=unused-argument,unsubscriptable-object,unsupported-membership-test,too-many-statements,too-many-locals |
| 47 | +# pylint: disable=unused-argument,unsubscriptable-object,unsupported-membership-test,too-many-statements,too-many-locals,broad-exception-caught |
48 | 48 |
|
49 | 49 |
|
50 | 50 | logger = get_logger(__name__) |
@@ -319,7 +319,7 @@ def connection_create(cmd, client, # pylint: disable=too-many-locals,too-many-s |
319 | 319 | connstr_props=None, # Resource.FabricSql |
320 | 320 | fabric_workspace_uuid=None, |
321 | 321 | fabric_sql_db_uuid=None, |
322 | | - force=False, |
| 322 | + no_recreate=False, |
323 | 323 | ): |
324 | 324 | auth_action = 'optOutAllAuth' if (opt_out_list is not None and |
325 | 325 | OPT_OUT_OPTION.AUTHENTICATION.value in opt_out_list) else None |
@@ -373,12 +373,12 @@ def connection_create(cmd, client, # pylint: disable=too-many-locals,too-many-s |
373 | 373 | enable_appconfig_extension=enable_appconfig_extension, |
374 | 374 | server=server, database=database, |
375 | 375 | connstr_props=connstr_props, |
376 | | - force=force, |
| 376 | + no_recreate=no_recreate, |
377 | 377 | ) |
378 | 378 |
|
379 | 379 |
|
380 | 380 | # The function is used in extension, new feature must be added in the end for backward compatibility |
381 | | -def connection_create_func(cmd, client, # pylint: disable=too-many-locals,too-many-statements |
| 381 | +def connection_create_func(cmd, client, # pylint: disable=too-many-locals,too-many-statements,too-many-branches |
382 | 382 | connection_name=None, client_type=None, |
383 | 383 | source_resource_group=None, source_id=None, |
384 | 384 | target_resource_group=None, target_id=None, |
@@ -409,7 +409,7 @@ def connection_create_func(cmd, client, # pylint: disable=too-many-locals,too-m |
409 | 409 | target_app_name=None, # Resource.ContainerApp |
410 | 410 | enable_appconfig_extension=False, |
411 | 411 | connstr_props=None, # Resource.FabricSql |
412 | | - force=False, |
| 412 | + no_recreate=False, |
413 | 413 | **kwargs, |
414 | 414 | ): |
415 | 415 | if not source_id: |
@@ -534,10 +534,19 @@ def connection_create_func(cmd, client, # pylint: disable=too-many-locals,too-m |
534 | 534 | 'manually and then create the connection.'.format(str(e))) |
535 | 535 |
|
536 | 536 | validate_service_state(parameters) |
537 | | - linker = todict(client.get(resource_uri=source_id, linker_name=connection_name)) |
538 | | - if (linker is not None and not compare_properties_changed(parameters, linker) and force is False): |
539 | | - logger.warning('Connection exists and no property to be updated, skip the update operation. Use --force to force the connection recreation') |
540 | | - return linker |
| 537 | + try: |
| 538 | + linker = todict(client.get(resource_uri=source_id, linker_name=connection_name)) |
| 539 | + logger.warning('provisioningState of existing connection: %s', linker.get('provisioningState')) |
| 540 | + if linker is not None and linker.get('provisioningState') == 'Accepted': |
| 541 | + logger.warning('Connection provisioningState is Accepted, please retry later to avoid conflict.') |
| 542 | + return linker |
| 543 | + if linker is not None and linker.get('provisioningState') == 'Succeeded' and \ |
| 544 | + not compare_properties_changed(parameters, linker) and no_recreate is True: |
| 545 | + logger.warning( |
| 546 | + 'Connection exists and no property to be updated, skip the update operation.') |
| 547 | + return linker |
| 548 | + except Exception as e: |
| 549 | + logger.debug('No existing connection, start creating a new one. Error: %s', e) |
541 | 550 |
|
542 | 551 | if enable_mi_for_db_linker and auth_action != 'optOutAllAuth': |
543 | 552 | new_auth_info = enable_mi_for_db_linker( |
|
0 commit comments