Skip to content

Azure Cli restore AKS form backup #32458

@infrontleong

Description

@infrontleong

Describe the bug

Based on chatgpt, Azure CLI bug inside the dataprotection extension — NOT my script problem.

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

After run command but stuck in
az dataprotection backup-instance restore initialize-for-data-recovery

example command

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

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 "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 666, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 726, in _run_job
File "C:\Users\yukleong.chow.azure\cliextensions\dataprotection\azext_dataprotection\manual_exception_handler.py", line 13, in exception_handler
raise ex
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 703, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 336, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "C:\Users\yukleong.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,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
None, None, None, None, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yukleong.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

any solution ,already latest version for az extension update --name dataprotection

Related command

PS C:\Windows\system32> az dataprotection backup-instance restore initialize-for-data-recovery `

--datasource-type AzureKubernetesService `
--restore-location $region `
--source-datastore VaultStore `
--recovery-point-id $recoverypointid `
--restore-configuration restoreconfig.json `
--target-resource-id $targetresourceid associated with a value

Errors

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 "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 666, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 734, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 726, in _run_job
File "C:\Users\yukleong.chow.azure\cliextensions\dataprotection\azext_dataprotection\manual_exception_handler.py", line 13, in exception_handler
raise ex
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 703, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 336, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "C:\Users\yukleong.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,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
None, None, None, None, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yukleong.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

Issue script & Debug output

Expected behavior

expected successful

Environment Summary

azure version 2.80.0
az extension update --name dataprotection

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Data ProtectionService AttentionThis issue is responsible by Azure service team.bugThis 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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions