Skip to content

Azure CLI version 2.57 az backup create failure #28400

@DFranc-D

Description

@DFranc-D

Describe the bug

I tried using the cli create a backup policy for my Azure File Share, and no matter how the command was issued. Here are the commands I tried after creating my storage account and vault:
azureuser:~$ az backup policy create --backup-management-type AzureStorage --name DailyPolicy --policy "{ "type": "AzureFileShare ", "schedulePolicy": { "scheduleRunDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], "scheduleRunFrequency": "Daily", "scheduleRunTimes": ["19:30"] }, "retentionPolicy": { "dailySchedule": [ { "retentionDurationCount": 30, "retentionDuration": "Days", "dailyRetentionFormat": "at7:30PM" } ] }}" --resource-group my-resource-group --vault-name myRecoveryServicesVault --workload-type AzureFileShare

Related command

az backup policy create
--backup-management-type AzureStorage
--name DailyPolicy
--policy "/c/temp2/DailyPolicy.json"
--resource-group my-resource-group
--subscription 9f21ef71-545e-49b9-90ae-b90019419808
--vault-name myRecoveryServicesVault

I even made the json file simpler like this

azureuser:~$ cat /c/temp2/DailyPolicy.json
{
"type": "AzureFileShare",
"backupManagementType": "AzureStorage",
"schedulePolicy": {
"scheduleRunDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": ["19:30"]
},
"retentionPolicy": {
"dailySchedule": [
{
"retentionDurationCount": 30,
"retentionDuration": "Days"
}
]
}
}

Errors

The command failed with an unexpected error. Here is the traceback:
'NoneType' object has no attribute 'backup_management_type'
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 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 729, 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 721, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/_exception_handler.py", line 11, in backup_exception_handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 698, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_base.py", line 46, in create_policy
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_afs.py", line 370, in create_policy
AttributeError: 'NoneType' object has no attribute 'backup_management_type'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

azureuser:~$ az backup policy create --backup-management-type AzureStorage --name DailyPolicy --policy "{ "type": "AzureFileShare ", "schedulePolicy": { "scheduleRunDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], "scheduleRunFrequency": "Daily", "scheduleRunTimes": ["19:30"] }, "retentionPolicy": { "dailySchedule": [ { "retentionDurationCount": 30, "retentionDuration": "Days", "dailyRetentionFormat": "at7:30PM" } ] }}" --resource-group my-resource-group --vault-name myRecoveryServicesVault --workload-type AzureFileShare --debug
cli.knack.log: File logging enabled - writing logs to 'C:\Users\franc.azure\logs'.
cli.knack.cli: Command arguments: ['backup', 'policy', 'create', '--backup-management-type', 'AzureStorage', '--name', 'DailyPolicy', '--policy', '{ "type": "AzureFileShare ", "schedulePolicy": { "scheduleRunDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], "scheduleRunFrequency": "Daily", "scheduleRunTimes": ["19:30"] }, "retentionPolicy": { "dailySchedule": [ { "retentionDurationCount": 30, "retentionDuration": "Days", "dailyRetentionFormat": "at7:30PM" } ] }}', '--resource-group', 'my-resource-group', '--vault-name', 'myRecoveryServicesVault', '--workload-type', 'AzureFileShare', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x000001C3D686F920>, <function OutputProducer.on_global_arguments at 0x000001C3D69F60C0>, <function CLIQuery.on_global_arguments at 0x000001C3D6A23C40>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'backup': ['azure.cli.command_modules.backup']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: backup 0.007 16 60
cli.azure.cli.core: Total (1) 0.007 16 60
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 16 groups, 60 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : backup policy create
cli.azure.cli.core: Command table: backup policy create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001C3D993EAC0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\franc.azure\commands\2024-02-19.18-13-36.backup_policy_create.69196.log'.
az_command_data_logger: command args: backup policy create --backup-management-type {} --name {} --policy {} --resource-group {} --vault-name {} --workload-type {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x000001C3D999D080>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x000001C3D999D120>, <function register_cache_arguments..add_cache_arguments at 0x000001C3D999D260>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000001C3D69F6160>, <function CLIQuery.handle_query_parameter at 0x000001C3D6A23CE0>, <function register_ids_argument..parse_ids_arguments at 0x000001C3D999D1C0>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=RecoveryServicesBackupClient
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\Users\franc\.azure\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\franc.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/2e1bcd27-f03c-4185-9eeb-2c0bfd96d3c1/kerberos', 'tenant_region_scope': 'NA', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? False
cli.azure.cli.core.azclierror: 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 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 729, 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 721, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/_exception_handler.py", line 11, in backup_exception_handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 698, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_base.py", line 46, in create_policy
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_afs.py", line 370, in create_policy
AttributeError: 'NoneType' object has no attribute 'backup_management_type'

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'backup_management_type'
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 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 729, 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 721, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/_exception_handler.py", line 11, in backup_exception_handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 698, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_base.py", line 46, in create_policy
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_afs.py", line 370, in create_policy
AttributeError: 'NoneType' object has no attribute 'backup_management_type'
az_command_data_logger: 'NoneType' object has no attribute 'backup_management_type'
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 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 729, 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 721, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/_exception_handler.py", line 11, in backup_exception_handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 698, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_base.py", line 46, in create_policy
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_afs.py", line 370, in create_policy
AttributeError: 'NoneType' object has no attribute 'backup_management_type'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001C3D993ED40>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 0.930 seconds (init: 0.444, invoke: 0.486)

Expected behavior

I was hoping I could have my policy created with CLI so I could complete my project.

Environment Summary

azureuser:~$ az --version
azure-cli 2.57.0

core 2.57.0
telemetry 1.1.0

Extensions:
dataprotection 0.11.2

Dependencies:
msal 1.26.0
azure-mgmt-resource 23.1.0b2

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\franc.azure\cliextensions'

Python (Windows) 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

I added the az dataprotection for an alternative but it is only a work around that I have not had the chance to play with it since it is still in the experimental stage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignAuto assign by botRecovery Services Backupaz backupService AttentionThis issue is responsible by Azure service team.act-observability-squadbugThis 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