Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _common_client_factory(cli_ctx, **_):


def _backup_client_factory(cli_ctx, **_):
from azure.mgmt.recoveryservicesbackup.activestamp import RecoveryServicesBackupClient
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
Comment thread
vidyadharijami marked this conversation as resolved.
from azure.cli.core.commands.client_factory import get_mgmt_service_client

return get_mgmt_service_client(cli_ctx, RecoveryServicesBackupClient)
Expand Down Expand Up @@ -128,6 +128,10 @@ def backup_protected_items_cf(cli_ctx, *_):
return _backup_client_factory(cli_ctx).backup_protected_items


def configure_source_scan_cf(cli_ctx, *_):
return _backup_client_factory(cli_ctx).configure_source_scan


def backup_protected_items_crr_cf(cli_ctx, *_):
return _backup_passive_client_factory(cli_ctx).backup_protected_items_crr

Expand Down
15 changes: 15 additions & 0 deletions src/azure-cli/azure/cli/command_modules/backup/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@
crafted: true
"""

helps['backup item source-scan-configuration'] = """
type: group
short-summary: Manage Source Scan configuration for a backed up Azure VM item.
"""

helps['backup item source-scan-configuration set'] = """
type: command
short-summary: Set the Source Scan configuration used by Microsoft Defender for Cloud threat detection.
examples:
- name: Enable Source Scan for a backed up Azure VM item.
text: az backup item source-scan-configuration set --resource-group MyResourceGroup --vault-name MyVault --container-name MyContainer --name MyItem --state Enabled --backup-management-type AzureIaasVM --workload-type VM
- name: Disable Source Scan for a backed up Azure VM item.
text: az backup item source-scan-configuration set --resource-group MyResourceGroup --vault-name MyVault --container-name MyContainer --name MyItem --state Disabled --backup-management-type AzureIaasVM --workload-type VM
"""

helps['backup job'] = """
type: group
short-summary: Entity which contains details of the job.
Expand Down
10 changes: 10 additions & 0 deletions src/azure-cli/azure/cli/command_modules/backup/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def load_arguments(self, _):
c.argument('tags', arg_type=tags_type)
c.argument('classic_alerts', arg_type=get_enum_type(enable_disable_options), help='Use this property to specify whether backup alerts from the classic solution should be received.')
c.argument('public_network_access', arg_type=get_enum_type(enable_disable_options), help='Use this property to specify whether public network access for the vault should be enabled or disabled. It is enabled by default. For setting up private endpoints, it has to be disabled.')
c.argument('source_scan_state', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Configure the Source Scan state used by Microsoft Defender for Cloud threat detection.')
c.argument('azure_monitor_alerts_for_job_failures', options_list=['--job-failure-alerts'], arg_type=get_enum_type(enable_disable_options), help='Use this property to specify whether built-in Azure Monitor alerts should be received for every job failure.')
c.argument('immutability_state', arg_type=get_enum_type(allowed_immutability_options), help='Use this parameter to configure immutability settings for the vault. By default, immutability is "Disabled" for the vault. "Unlocked" means that immutability is enabled for the vault and can be reversed. "Locked" means that immutability is enabled for the vault and cannot be reversed.')
c.argument('cross_subscription_restore_state', arg_type=get_enum_type(enable_disable_permadisable_options), help='Use this parameter to configure cross subscription restore settings for the vault. By default, the property is "Enabled" for the vault.')
Expand Down Expand Up @@ -232,6 +233,15 @@ def load_arguments(self, _):
c.argument('workload_type', workload_type)
c.argument('use_secondary_region', action='store_true', help='Use this flag to list items in secondary region.')

with self.argument_context('backup item source-scan-configuration set') as c:
c.argument('name', item_name_type, options_list=['--name', '-n'], help='Name of the backed up Azure VM item.', id_part=None)
c.argument('container_name', container_name_type, id_part=None)
c.argument('backup_management_type', arg_type=get_enum_type(['AzureIaasVM']),
help='Type of backup management for the item.')
c.argument('workload_type', arg_type=get_enum_type(['VM']),
help='Type of workload protected by the item.')
c.argument('state', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Source Scan state used by Microsoft Defender for Cloud threat detection.')

# Policy
with self.argument_context('backup policy') as c:
c.argument('vault_name', vault_name_type, id_part='name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datetime import datetime
from azure.cli.core.azclierror import RequiredArgumentMissingError, MutuallyExclusiveArgumentError, \
ArgumentUsageError, InvalidArgumentValueError
from azure.mgmt.recoveryservicesbackup.activestamp.models import StorageType
from azure.mgmt.recoveryservicesbackup.models import StorageType
# Argument types


Expand Down
27 changes: 18 additions & 9 deletions src/azure-cli/azure/cli/command_modules/backup/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
job_cancellations_cf, recovery_points_cf, restores_cf, backup_storage_configs_non_crr_cf,
item_level_recovery_connections_cf, backup_protected_items_cf, backup_protectable_items_cf,
protection_containers_cf, protection_intent_cf, backup_resource_encryption_config_cf,
resource_guard_proxy_cf, deleted_protection_containers_cf) # pylint: disable=unused-variable
resource_guard_proxy_cf, deleted_protection_containers_cf,
configure_source_scan_cf) # pylint: disable=unused-variable
from azure.cli.command_modules.backup._exception_handler import backup_exception_handler
from azure.cli.command_modules.backup._format import (
transform_container_list, transform_policy_list, transform_item_list, transform_job_list,
Expand Down Expand Up @@ -59,8 +60,10 @@ def load_command_table(self, _):
g.show_command('list-soft-deleted-containers', 'list_deleted_protection_containers')

with self.command_group('backup container', backup_custom_base, client_factory=protection_containers_cf, exception_handler=backup_exception_handler) as g:
g.show_command('show', 'show_container', client_factory=backup_protection_containers_cf, table_transformer=transform_container)
g.command('list', 'list_containers', table_transformer=transform_container_list, client_factory=backup_protection_containers_cf)
g.show_command('show', 'show_container_with_hybrid_properties',
client_factory=backup_protection_containers_cf, table_transformer=transform_container)
g.command('list', 'list_containers_with_hybrid_properties',
table_transformer=transform_container_list, client_factory=backup_protection_containers_cf)

with self.command_group('backup container', custom_command_type=backup_custom_base, client_factory=protection_containers_cf, exception_handler=backup_exception_handler) as g:
g.custom_command('unregister', 'unregister_container', confirmation=True)
Expand Down Expand Up @@ -95,13 +98,18 @@ def load_command_table(self, _):
g.custom_command('reconfigure', 'reconfigure_backup_protection', client_factory=backup_protected_items_cf)

with self.command_group('backup item', backup_custom_base, client_factory=protected_items_cf, exception_handler=backup_exception_handler) as g:
g.show_command('show', 'show_item', client_factory=backup_protected_items_cf, table_transformer=transform_item)
g.command('list', 'list_items', table_transformer=transform_item_list, client_factory=backup_protected_items_cf)
g.show_command('show', 'show_item_with_hybrid_properties', client_factory=backup_protected_items_cf,
table_transformer=transform_item)
g.command('list', 'list_items_with_hybrid_properties', table_transformer=transform_item_list,
client_factory=backup_protected_items_cf)
g.command('set-policy', 'update_policy_for_item', table_transformer=transform_job)
g.command('source-scan-configuration set', 'set_item_source_scan_configuration',
client_factory=configure_source_scan_cf)

with self.command_group('backup protectable-item', backup_custom_base, client_factory=backup_protectable_items_cf, exception_handler=backup_exception_handler) as g:
g.show_command('show', 'show_protectable_item')
g.command('list', 'list_protectable_items', table_transformer=transform_protectable_item_list)
g.show_command('show', 'show_protectable_item_with_hybrid_properties')
g.command('list', 'list_protectable_items_with_hybrid_properties',
table_transformer=transform_protectable_item_list)
g.command('initialize', 'initialize_protectable_items', client_factory=protection_containers_cf)

with self.command_group('backup job', backup_custom, client_factory=job_details_cf, exception_handler=backup_exception_handler) as g:
Expand All @@ -111,8 +119,9 @@ def load_command_table(self, _):
g.command('wait', 'wait_for_job')

with self.command_group('backup recoverypoint', backup_custom_base, client_factory=recovery_points_cf, exception_handler=backup_exception_handler) as g:
g.show_command('show', 'show_recovery_point')
g.command('list', 'list_recovery_points', table_transformer=transform_recovery_point_list)
g.show_command('show', 'show_recovery_point_with_hybrid_properties')
g.command('list', 'list_recovery_points_with_hybrid_properties',
table_transformer=transform_recovery_point_list)
g.command('move', 'move_recovery_points')
g.show_command('show-log-chain', 'show_log_chain_recovery_points', table_transformer=transform_log_chain_list)

Expand Down
Loading
Loading