Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 2 additions & 4 deletions src/azure-cli/azure/cli/command_modules/resource/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2262,11 +2262,9 @@

helps['ts export'] = """
type: command
short-summary: Export the specified template spec and artifacts (if any) to the specified output folder.
short-summary: Export the specified template spec version and artifacts (if any) to the specified output folder.
examples:
- name: Export the specified template spec with all versions.
text: az ts export -g testrg --name TemplateSpecName --output-folder C:/path/
- name: Export the specified template spec.
- name: Export the specified template spec version based on resource ID.
text: az ts export -s resourceID --output-folder C:/path/
- name: Export the specified template spec version.
text: az ts export -g testrg --name TemplateSpecName --version VersionName --output-folder C:/path/
Expand Down
9 changes: 7 additions & 2 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,10 @@ def get_template_spec(cmd, resource_group_name=None, name=None, version=None, te
rcf = _resource_templatespecs_client_factory(cmd.cli_ctx)
if version:
return rcf.template_spec_versions.get(resource_group_name, name, version)
return rcf.template_specs.get(resource_group_name, name)
retrieved_template = rcf.template_specs.get(resource_group_name, name, expand="versions")
version_names = list(retrieved_template.versions.keys())
retrieved_template.versions = version_names
return retrieved_template


def create_template_spec(cmd, resource_group_name, name, template_file=None, location=None, display_name=None,
Expand Down Expand Up @@ -1935,7 +1938,9 @@ def export_template_spec(cmd, output_folder, resource_group_name=None, name=None
version = id_parts.get('resource_name')
if version == name:
version = None
exported_template = rcf.template_spec_versions.get(resource_group_name, name, version) if version else rcf.template_specs.get(resource_group_name, name)
if not version:
raise IncorrectUsageError('a template spec version must be specified for export')
Comment thread
detienne20 marked this conversation as resolved.
Outdated
exported_template = rcf.template_spec_versions.get(resource_group_name, name, version)
from azure.cli.command_modules.resource._packing_engine import (unpack)
return unpack(cmd, exported_template, output_folder, (str(name) + '.JSON'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interactions:
ParameterSetName:
- -g -n -v -l -f --description --version-description
User-Agent:
- python/3.8.3 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1
- python/3.8.7 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.19.0
accept-language:
- en-US
method: GET
Expand All @@ -32,7 +32,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 07 Jan 2021 17:53:56 GMT
- Tue, 09 Feb 2021 17:41:10 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -60,8 +60,8 @@ interactions:
ParameterSetName:
- -g -n -v -l -f --description --version-description
User-Agent:
- python/3.8.3 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1
- python/3.8.7 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.19.0
accept-language:
- en-US
method: GET
Expand All @@ -79,7 +79,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 07 Jan 2021 17:53:57 GMT
- Tue, 09 Feb 2021 17:41:10 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -112,8 +112,8 @@ interactions:
ParameterSetName:
- -g -n -v -l -f --description --version-description
User-Agent:
- python/3.8.3 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1
- python/3.8.7 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.19.0
accept-language:
- en-US
method: PUT
Expand All @@ -122,9 +122,9 @@ interactions:
body:
string: "{\r\n \"location\": \"westus\",\r\n \"tags\": {},\r\n \"systemData\":
{\r\n \"createdBy\": \"daetienn@microsoft.com\",\r\n \"createdByType\":
\"User\",\r\n \"createdAt\": \"2021-01-07T17:53:59.5486662Z\",\r\n \"lastModifiedBy\":
\"User\",\r\n \"createdAt\": \"2021-02-09T17:41:13.1182977Z\",\r\n \"lastModifiedBy\":
\"daetienn@microsoft.com\",\r\n \"lastModifiedByType\": \"User\",\r\n \"lastModifiedAt\":
\"2021-01-07T17:53:59.5486662Z\"\r\n },\r\n \"properties\": {\r\n \"description\":
\"2021-02-09T17:41:13.1182977Z\"\r\n },\r\n \"properties\": {\r\n \"description\":
\"AzCLI test root template spec\"\r\n },\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_template_specs000001/providers/Microsoft.Resources/templateSpecs/cli-test-create-template-spec000002\",\r\n
\ \"type\": \"Microsoft.Resources/templateSpecs\",\r\n \"name\": \"cli-test-create-template-spec000002\"\r\n}"
headers:
Expand All @@ -135,7 +135,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 07 Jan 2021 17:53:59 GMT
- Tue, 09 Feb 2021 17:41:12 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -244,8 +244,8 @@ interactions:
ParameterSetName:
- -g -n -v -l -f --description --version-description
User-Agent:
- python/3.8.3 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1
- python/3.8.7 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.19.0
accept-language:
- en-US
method: PUT
Expand All @@ -254,9 +254,9 @@ interactions:
body:
string: "{\r\n \"location\": \"westus\",\r\n \"tags\": {},\r\n \"systemData\":
{\r\n \"createdBy\": \"daetienn@microsoft.com\",\r\n \"createdByType\":
\"User\",\r\n \"createdAt\": \"2021-01-07T17:54:00.8486769Z\",\r\n \"lastModifiedBy\":
\"User\",\r\n \"createdAt\": \"2021-02-09T17:41:14.4233826Z\",\r\n \"lastModifiedBy\":
\"daetienn@microsoft.com\",\r\n \"lastModifiedByType\": \"User\",\r\n \"lastModifiedAt\":
\"2021-01-07T17:54:00.8486769Z\"\r\n },\r\n \"properties\": {\r\n \"artifacts\":
\"2021-02-09T17:41:14.4233826Z\"\r\n },\r\n \"properties\": {\r\n \"artifacts\":
[],\r\n \"description\": \"AzCLI test version of root template spec\",\r\n
\ \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\r\n
\ \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"customer\":
Expand Down Expand Up @@ -385,7 +385,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 07 Jan 2021 17:54:00 GMT
- Tue, 09 Feb 2021 17:41:14 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -417,8 +417,8 @@ interactions:
ParameterSetName:
- --template-spec --yes
User-Agent:
- python/3.8.3 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1
- python/3.8.7 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3
azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.19.0
accept-language:
- en-US
method: DELETE
Expand All @@ -432,7 +432,7 @@ interactions:
content-length:
- '0'
date:
- Thu, 07 Jan 2021 17:54:03 GMT
- Tue, 09 Feb 2021 17:41:17 GMT
expires:
- '-1'
pragma:
Expand Down
Loading