Skip to content

Commit c3dfa82

Browse files
author
Zubair Abid
committed
Added warning message for standard -> enhanced policy migration
1 parent 03ad904 commit c3dfa82

File tree

1 file changed

+12
-2
lines changed
  • src/azure-cli/azure/cli/command_modules/backup

1 file changed

+12
-2
lines changed

src/azure-cli/azure/cli/command_modules/backup/custom.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@
126126
os_linux = 'Linux'
127127
password_offset = 33
128128
password_length = 15
129+
enhanced_policy_type = "v2"
130+
standard_policy_type = "v1"
129131
# pylint: disable=too-many-function-args
130132

131133

@@ -1004,16 +1006,24 @@ def update_policy_for_item(cmd, client, resource_group_name, vault_name, item, p
10041006
vm_item_properties.policy_id = policy.id
10051007
vm_item_properties.source_resource_id = item.properties.source_resource_id
10061008
vm_item = ProtectedItemResource(properties=vm_item_properties)
1009+
existing_policy = common.show_policy(protection_policies_cf(cmd.cli_ctx), resource_group_name, vault_name,
1010+
item.properties.policy_name)
10071011
if is_critical_operation:
1008-
existing_policy = common.show_policy(protection_policies_cf(cmd.cli_ctx), resource_group_name, vault_name,
1009-
item.properties.policy_name)
10101012
if cust_help.is_retention_duration_decreased(existing_policy, policy, "AzureIaasVM"):
10111013
# update the payload with critical operation and add auxiliary header for cross tenant case
10121014
if tenant_id is not None:
10131015
client = get_mgmt_service_client(cmd.cli_ctx, RecoveryServicesBackupClient,
10141016
aux_tenants=[tenant_id]).protected_items
10151017
vm_item.properties.resource_guard_operation_requests = [cust_help.get_resource_guard_operation_request(
10161018
cmd.cli_ctx, resource_group_name, vault_name, "updateProtection")]
1019+
1020+
# Raise warning for standard->enhanced policy
1021+
existing_policy_type = enhanced_policy_type if existing_policy.properties.policy_type.lower() == "v2" else standard_policy_type
1022+
new_policy_type = enhanced_policy_type if policy.properties.policy_type.lower() == "v2" else standard_policy_type
1023+
if (new_policy_type == enhanced_policy_type and existing_policy_type == existing_policy_type):
1024+
logger.warning('Upgrading to enhanced policy can incur additional charges. Once upgraded to the enhanced '
1025+
'policy, it is not possible to revert back to the standard policy.')
1026+
10171027
# Update policy
10181028
result = client.create_or_update(vault_name, resource_group_name, fabric_name,
10191029
container_uri, item_uri, vm_item, cls=cust_help.get_pipeline_response)

0 commit comments

Comments
 (0)