Azure / Azure/azure-cli

Azure CLI version 2.57 az backup create failure

Open
#28,400 2 comments 1 reaction 0 assignees View on GitHub
act-observability-squad Auto-Assign bug customer-reported Recovery Services Backup Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### 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 [, , ]
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 []
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 [.add_subscription_parameter at 0x000001C3D999D080>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x000001C3D999D120>, .add_cache_arguments at 0x000001C3D999D260>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .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 []
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.