Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Azure CLI Debug (Integrated Console)",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"pythonPath": "${config:python.interpreterPath}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it modified here?

"program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
Expand All @@ -24,7 +24,7 @@
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"pythonPath": "${config:python.interpreterPath}",
"program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
Expand All @@ -40,7 +40,7 @@
"name": "Azdev Scripts",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"pythonPath": "${config:python.interpreterPath}",
"program": "${workspaceRoot}/tools/automation/__main__.py",
"cwd": "${workspaceRoot}",
"args": [
Expand Down
25 changes: 21 additions & 4 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,14 @@ def update_resource_group(instance, tags=None):


def export_group_as_template(
cmd, resource_group_name, include_comments=False, include_parameter_default_value=False):
cmd, resource_group_name, resource_ids=None, include_comments=False, include_parameter_default_value=False, skip_resource_name_parameterization=False, skip_all_parameterization=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

resource_ids=None It is recommended to put the new parameters after the existing parameter of the method

Copy link
Contributor

Choose a reason for hiding this comment

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

--skip-all-parameterization and --skip-resource-name-parameterization are too long for the customers to input. Could you make them shorter?

Copy link

@azcloudfarmer azcloudfarmer May 22, 2020

Choose a reason for hiding this comment

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

How about --skip-all-params and --skip-resource-name-params? @jorgecotillo

"""Captures a resource group as a template.
:param str resource_group_name:the name of the resoruce group.
:param bool include_comments:export template with comments.
:param str resource_group_name: the name of the resource group.
:param str resource_ids: a string containing space-separated resource ids to filter the export by. To export all resources, do not specify this argument or supply "*".
:param bool include_comments: export template with comments.
:param bool include_parameter_default_value: export template parameter with default value.
:param bool skip_resource_name_parameterization: export template and skip resource name parameterization.
:param bool skip_all_parameterization: export template parameter and skip all parameterization.
"""
rcf = _resource_client_factory(cmd.cli_ctx)

Expand All @@ -1038,10 +1041,24 @@ def export_group_as_template(
export_options.append('IncludeComments')
if include_parameter_default_value:
export_options.append('IncludeParameterDefaultValue')
if skip_resource_name_parameterization:
export_options.append('SkipResourceNameParameterization')
if skip_all_parameterization:
export_options.append('SkipAllParameterization')

resources = []
if resource_ids is None or resource_ids == "*":
Copy link
Member

Choose a reason for hiding this comment

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

resource_ids [](start = 31, length = 12)

just to confirm here if it should be resource_ids[0] == "*"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the code.

resources = ["*"]
else:
for i in resource_ids.split():
if is_valid_resource_id(i):
resources.append(i)
else:
raise CLIError('az resource: error: argument --resource_ids: invalid ResourceId value: \'%s\'' % i)

Copy link
Contributor

Choose a reason for hiding this comment

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

--resource_ids --> --resource-ids

options = ','.join(export_options) if export_options else None

result = rcf.resource_groups.export_template(resource_group_name, ['*'], options=options)
result = rcf.resource_groups.export_template(resource_group_name, resources, options=options)

# pylint: disable=no-member
# On error, server still returns 200, with details in the error attribute
Expand Down
Loading