Skip to content

Azure CLI restore AKS have bug/issue (az dataprotection backup-instance restore initialize-for-data-recovery) #32465

@infrontleong

Description

@infrontleong

Describe the bug

URL link : https://learn.microsoft.com/en-us/azure/backup/azure-kubernetes-service-cluster-restore-using-cli#prepare-the-restore-request

Command az dataprotection backup-instance restore initialize-for-data-recovery

I am using azure cli latest version and run az extension add --name dataprotection,

  • look like the container_list_present Python bug

  • CLI cannot run the restore because of an internal bug in the Azure Data Protection extension

During Prepare the restore request have issue

  1. After run this command , successfully,

az dataprotection backup-instance initialize-restoreconfig --datasource-type AzureKubernetesService >restoreconfig.json

  1. run this, failed
    az dataprotection backup-instance restore initialize-for-data-recovery --datasource-type AzureKubernetesService --restore-location $region --source-datastore OperationalStore --recovery-point-id $recoverypointid --restore-configuration restoreconfig.json --target-resource-id /subscriptions/$subscriptionId/resourceGroups/$aksclusterresourcegroup/providers/Microsoft.ContainerService/managedClusters/$targetakscluster

restorerequestobject.json

Error code

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: cannot access local variable 'container_list_present' where it is not associated with a value
Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 726, in _run_job
return cmd_copy.exception_handler(ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chow/.azure/cliextensions/dataprotection/azext_dataprotection/manual/_exception_handler.py", line 13, in exception_handler
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/chow/.azure/cliextensions/dataprotection/azext_dataprotection/manual/custom.py", line 1119, in restore_initialize_for_item_recovery
restore_request["restore_target_info"]["restore_criteria"] = helper.get_resource_criteria_list(datasource_type, restore_configuration,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chow/.azure/cliextensions/dataprotection/azext_dataprotection/manual/helpers.py", line 562, in get_resource_criteria_list
if container_list_present:
^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'container_list_present' where it is not associated with a value
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Related command

az dataprotection backup-instance restore initialize-for-data-recovery
--datasource-type AzureKubernetesService
--restore-location $region
--source-datastore OperationalStore
--recovery-point-id $recoverypointid
--restore-configuration restoreconfig.json
--target-resource-id $targetresourceid

Errors

Issue script & Debug output

The command failed with an unexpected error. Here is the traceback:
cannot access local variable 'container_list_present' where it is not associated with a value
Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 726, in _run_job
return cmd_copy.exception_handler(ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chow/.azure/cliextensions/dataprotection/azext_dataprotection/manual/_exception_handler.py", line 13, in exception_handler
raise ex
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/home/chow/.azure/cliextensions/dataprotection/azext_dataprotection/manual/custom.py", line 1005, in restore_initialize_for_data_recovery
restore_request["restore_target_info"]["restore_criteria"] = helper.get_resource_criteria_list(datasource_type, restore_configuration,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chow/.azure/cliextensions/dataprotection/azext_dataprotection/manual/helpers.py", line 562, in get_resource_criteria_list
if container_list_present:
^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'container_list_present' where it is not associated with a value

Expected behavior

Environment Summary

azure cli latest version
az extension add --name dataprotection

Additional context

Anyone facing same issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Data ProtectionService AttentionThis issue is responsible by Azure service team.Similar-IssuebugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions