Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 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 @@ -75,6 +75,9 @@ def load_arguments(self, _):
c.argument('vault_name', vault_name_type, options_list=['--name', '-n'], id_part='name')
c.argument('location', validator=get_default_location_from_resource_group)

with self.argument_context('backup vault create') as c:
c.argument('tags', type=file_type, help='JSON encoded tags. Use the show command with JSON output to see tags format. Modify the values accordingly using a file editor and pass the file path here.', completer=FilesCompleter())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also consider

tags_type = CLIArgumentType(
    validator=validate_tags,
    help="space-separated tags: key[=value] [key[=value] ...]. {}".format(quote_text),
    nargs='*'
)

tag_type = CLIArgumentType(
    type=validate_tag,
    help="a single tag in 'key[=value]' format. {}".format(quote_text),
    nargs='?',
    const=''
)


with self.argument_context('backup vault backup-properties set') as c:
c.argument('backup_storage_redundancy', arg_type=get_enum_type(['GeoRedundant', 'LocallyRedundant']), help='Sets backup storage properties for a Recovery Services vault.')
c.argument('soft_delete_feature_state', arg_type=get_enum_type(['Enable', 'Disable']), help='Set soft-delete feature state for a Recovery Services Vault.')
Expand Down
7 changes: 4 additions & 3 deletions src/azure-cli/azure/cli/command_modules/backup/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@
# pylint: disable=too-many-function-args


def create_vault(client, vault_name, resource_group_name, location):
def create_vault(client, vault_name, resource_group_name, location, tags=None):
vault_sku = Sku(name=SkuName.standard)
vault_properties = VaultProperties()

vault = Vault(location=location, sku=vault_sku, properties=vault_properties)
if tags is not None:
tags = _get_or_read_json(tags)
vault = Vault(location=location, sku=vault_sku, properties=vault_properties, tags=tags)
return client.create_or_update(resource_group_name, vault_name, vault)


Expand Down