diff --git a/doc/extensions/README.md b/doc/extensions/README.md index 2b6d1a01aef..46dd325ddbf 100644 --- a/doc/extensions/README.md +++ b/doc/extensions/README.md @@ -12,8 +12,6 @@ What is an Extension? - Currently, we support one extension type, a [Python Wheel](http://pythonwheels.com/). - All extension documentation here refers to this type of extension. -> Extensions should be built with wheel `0.29.0` or `0.30.0` until [#6441](https://github.com/Azure/azure-cli/issues/6441) is resolved - What an Extension is not ------------------------ diff --git a/src/azure-cli/azure/cli/command_modules/resource/_params.py b/src/azure-cli/azure/cli/command_modules/resource/_params.py index 0dbc20492d7..ab44b34422f 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_params.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_params.py @@ -365,6 +365,9 @@ def load_arguments(self, _): with self.argument_context('group export') as c: c.argument('include_comments', action='store_true') c.argument('include_parameter_default_value', action='store_true') + c.argument('skip_resource_name_params', action='store_true') + c.argument('skip_all_params', action='store_true') + c.argument('resource_ids', nargs='+', options_list='--resource-ids') with self.argument_context('group create') as c: c.argument('rg_name', options_list=['--name', '--resource-group', '-n', '-g'], diff --git a/src/azure-cli/azure/cli/command_modules/resource/custom.py b/src/azure-cli/azure/cli/command_modules/resource/custom.py index 9d8fd7dd5c0..6ea87ed7735 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -1032,11 +1032,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, include_comments=False, include_parameter_default_value=False, resource_ids=None, skip_resource_name_params=False, skip_all_params=False): """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 resource_ids: 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_params: export template and skip resource name parameterization. + :param bool skip_all_params: export template parameter and skip all parameterization. """ rcf = _resource_client_factory(cmd.cli_ctx) @@ -1045,10 +1048,24 @@ def export_group_as_template( export_options.append('IncludeComments') if include_parameter_default_value: export_options.append('IncludeParameterDefaultValue') + if skip_resource_name_params: + export_options.append('SkipResourceNameParameterization') + if skip_all_params: + export_options.append('SkipAllParameterization') + + resources = [] + if resource_ids is None or resource_ids[0] == "*": + resources = ["*"] + else: + for i in resource_ids: + if is_valid_resource_id(i): + resources.append(i) + else: + raise CLIError('az resource: error: argument --resource-ids: invalid ResourceId value: \'%s\'' % i) 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 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_resource_group_export_skip_all_params.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_resource_group_export_skip_all_params.yaml new file mode 100644 index 00000000000..da0d1319341 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_resource_group_export_skip_all_params.yaml @@ -0,0 +1,339 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-resource/9.0.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_rg_scenario000001?api-version=2019-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001","name":"cli_test_rg_scenario000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2020-05-22T18:17:08Z","StorageType":"testStrogae"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '456' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:12 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "westus", "tags": {}, "properties": {"addressSpace": {"addressPrefixes": + ["10.0.0.0/16"]}, "dhcpOptions": {}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + Content-Length: + - '123' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1?api-version=2020-04-01 + response: + body: + string: "{\r\n \"name\": \"vnet1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1\",\r\n + \ \"etag\": \"W/\\\"3f095d9a-b7cf-486d-b644-7099c50dcc97\\\"\",\r\n \"type\": + \"Microsoft.Network/virtualNetworks\",\r\n \"location\": \"westus\",\r\n + \ \"tags\": {\r\n \"costCenter\": \"Contoso/IT/PROD/123456\"\r\n },\r\n + \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \"resourceGuid\": + \"0d5b7728-2038-42d5-b9dd-c21e75ce962c\",\r\n \"addressSpace\": {\r\n \"addressPrefixes\": + [\r\n \"10.0.0.0/16\"\r\n ]\r\n },\r\n \"dhcpOptions\": + {\r\n \"dnsServers\": []\r\n },\r\n \"subnets\": [],\r\n \"virtualNetworkPeerings\": + [],\r\n \"enableDdosProtection\": false,\r\n \"enableVmProtection\": + false\r\n }\r\n}" + headers: + azure-asyncnotification: + - Enabled + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/westus/operations/14df1e47-c541-4d5e-af7d-2f785e0e6c8d?api-version=2020-04-01 + cache-control: + - no-cache + content-length: + - '814' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:13 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - 04d1546b-34c7-4ce8-80a7-c24e72f0cb2d + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/westus/operations/14df1e47-c541-4d5e-af7d-2f785e0e6c8d?api-version=2020-04-01 + response: + body: + string: "{\r\n \"status\": \"Succeeded\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '29' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - aeb586d8-c43b-47f6-ab07-b47b279ff40c + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1?api-version=2020-04-01 + response: + body: + string: "{\r\n \"name\": \"vnet1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1\",\r\n + \ \"etag\": \"W/\\\"b91ba743-3872-4739-978b-7fc25edcc7ad\\\"\",\r\n \"type\": + \"Microsoft.Network/virtualNetworks\",\r\n \"location\": \"westus\",\r\n + \ \"tags\": {\r\n \"costCenter\": \"Contoso/IT/PROD/123456\"\r\n },\r\n + \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"resourceGuid\": + \"0d5b7728-2038-42d5-b9dd-c21e75ce962c\",\r\n \"addressSpace\": {\r\n \"addressPrefixes\": + [\r\n \"10.0.0.0/16\"\r\n ]\r\n },\r\n \"dhcpOptions\": + {\r\n \"dnsServers\": []\r\n },\r\n \"subnets\": [],\r\n \"virtualNetworkPeerings\": + [],\r\n \"enableDdosProtection\": false,\r\n \"enableVmProtection\": + false\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '815' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:17 GMT + etag: + - W/"b91ba743-3872-4739-978b-7fc25edcc7ad" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - 19d437a8-19cd-45af-b63e-acf3cdd07908 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet show + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1?api-version=2020-04-01 + response: + body: + string: "{\r\n \"name\": \"vnet1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1\",\r\n + \ \"etag\": \"W/\\\"b91ba743-3872-4739-978b-7fc25edcc7ad\\\"\",\r\n \"type\": + \"Microsoft.Network/virtualNetworks\",\r\n \"location\": \"westus\",\r\n + \ \"tags\": {\r\n \"costCenter\": \"Contoso/IT/PROD/123456\"\r\n },\r\n + \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"resourceGuid\": + \"0d5b7728-2038-42d5-b9dd-c21e75ce962c\",\r\n \"addressSpace\": {\r\n \"addressPrefixes\": + [\r\n \"10.0.0.0/16\"\r\n ]\r\n },\r\n \"dhcpOptions\": + {\r\n \"dnsServers\": []\r\n },\r\n \"subnets\": [],\r\n \"virtualNetworkPeerings\": + [],\r\n \"enableDdosProtection\": false,\r\n \"enableVmProtection\": + false\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '815' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:17 GMT + etag: + - W/"b91ba743-3872-4739-978b-7fc25edcc7ad" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - 656853f2-0df3-4712-aedc-375b95f51af8 + status: + code: 200 + message: OK +- request: + body: 'b''{"resources": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1"], + "options": "SkipAllParameterization"}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - group export + Connection: + - keep-alive + Content-Length: + - '249' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --name --resource-ids --skip-all-params --query + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-resource/9.0.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_rg_scenario000001/exportTemplate?api-version=2019-07-01 + response: + body: + string: '{"template":{"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion":"1.0.0.0","parameters":{},"variables":{},"resources":[{"type":"Microsoft.Network/virtualNetworks","apiVersion":"2020-04-01","name":"vnet1","location":"westus","tags":{"costCenter":"Contoso/IT/PROD/123456"},"properties":{"addressSpace":{"addressPrefixes":["10.0.0.0/16"]},"dhcpOptions":{"dnsServers":[]},"subnets":[],"virtualNetworkPeerings":[],"enableDdosProtection":false,"enableVmProtection":false}}]}}' + headers: + cache-control: + - no-cache + content-length: + - '526' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:18 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_resource_group_export_skip_resource_name_params.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_resource_group_export_skip_resource_name_params.yaml new file mode 100644 index 00000000000..a2cce9ad533 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_resource_group_export_skip_resource_name_params.yaml @@ -0,0 +1,339 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-resource/9.0.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_rg_scenario000001?api-version=2019-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001","name":"cli_test_rg_scenario000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2020-05-22T18:17:20Z","StorageType":"testStrogae"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '456' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:21 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "westus", "tags": {}, "properties": {"addressSpace": {"addressPrefixes": + ["10.0.0.0/16"]}, "dhcpOptions": {}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + Content-Length: + - '123' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1?api-version=2020-04-01 + response: + body: + string: "{\r\n \"name\": \"vnet1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1\",\r\n + \ \"etag\": \"W/\\\"502789d8-3423-4424-95dc-b97440909032\\\"\",\r\n \"type\": + \"Microsoft.Network/virtualNetworks\",\r\n \"location\": \"westus\",\r\n + \ \"tags\": {\r\n \"costCenter\": \"Contoso/IT/PROD/123456\"\r\n },\r\n + \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \"resourceGuid\": + \"408830c3-6129-45f7-9e2a-850ba97ead27\",\r\n \"addressSpace\": {\r\n \"addressPrefixes\": + [\r\n \"10.0.0.0/16\"\r\n ]\r\n },\r\n \"dhcpOptions\": + {\r\n \"dnsServers\": []\r\n },\r\n \"subnets\": [],\r\n \"virtualNetworkPeerings\": + [],\r\n \"enableDdosProtection\": false,\r\n \"enableVmProtection\": + false\r\n }\r\n}" + headers: + azure-asyncnotification: + - Enabled + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/westus/operations/b9fe708e-fb2a-4ec7-80d7-5678a7e3f662?api-version=2020-04-01 + cache-control: + - no-cache + content-length: + - '814' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:22 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - 9725365a-a99d-4ebe-94b2-b7bf3899ba43 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/westus/operations/b9fe708e-fb2a-4ec7-80d7-5678a7e3f662?api-version=2020-04-01 + response: + body: + string: "{\r\n \"status\": \"Succeeded\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '29' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:25 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - f596e99e-ed89-454e-9ed8-6bd33c6ebe50 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1?api-version=2020-04-01 + response: + body: + string: "{\r\n \"name\": \"vnet1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1\",\r\n + \ \"etag\": \"W/\\\"7a4005ac-c22b-4101-bf9d-0560683ea6d4\\\"\",\r\n \"type\": + \"Microsoft.Network/virtualNetworks\",\r\n \"location\": \"westus\",\r\n + \ \"tags\": {\r\n \"costCenter\": \"Contoso/IT/PROD/123456\"\r\n },\r\n + \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"resourceGuid\": + \"408830c3-6129-45f7-9e2a-850ba97ead27\",\r\n \"addressSpace\": {\r\n \"addressPrefixes\": + [\r\n \"10.0.0.0/16\"\r\n ]\r\n },\r\n \"dhcpOptions\": + {\r\n \"dnsServers\": []\r\n },\r\n \"subnets\": [],\r\n \"virtualNetworkPeerings\": + [],\r\n \"enableDdosProtection\": false,\r\n \"enableVmProtection\": + false\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '815' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:26 GMT + etag: + - W/"7a4005ac-c22b-4101-bf9d-0560683ea6d4" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - bde6f765-dc7d-4e4c-9aa6-4168f9667d33 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network vnet show + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.1.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1?api-version=2020-04-01 + response: + body: + string: "{\r\n \"name\": \"vnet1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1\",\r\n + \ \"etag\": \"W/\\\"7a4005ac-c22b-4101-bf9d-0560683ea6d4\\\"\",\r\n \"type\": + \"Microsoft.Network/virtualNetworks\",\r\n \"location\": \"westus\",\r\n + \ \"tags\": {\r\n \"costCenter\": \"Contoso/IT/PROD/123456\"\r\n },\r\n + \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"resourceGuid\": + \"408830c3-6129-45f7-9e2a-850ba97ead27\",\r\n \"addressSpace\": {\r\n \"addressPrefixes\": + [\r\n \"10.0.0.0/16\"\r\n ]\r\n },\r\n \"dhcpOptions\": + {\r\n \"dnsServers\": []\r\n },\r\n \"subnets\": [],\r\n \"virtualNetworkPeerings\": + [],\r\n \"enableDdosProtection\": false,\r\n \"enableVmProtection\": + false\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '815' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:26 GMT + etag: + - W/"7a4005ac-c22b-4101-bf9d-0560683ea6d4" + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-arm-service-request-id: + - 0651653a-b767-4ce1-9121-dd8307263360 + status: + code: 200 + message: OK +- request: + body: 'b''{"resources": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rg_scenario000001/providers/Microsoft.Network/virtualNetworks/vnet1"], + "options": "SkipResourceNameParameterization"}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - group export + Connection: + - keep-alive + Content-Length: + - '258' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --name --resource-ids --skip-resource-name-params --query + User-Agent: + - python/3.7.7 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-resource/9.0.0 + Azure-SDK-For-Python AZURECLI/2.5.1 + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_rg_scenario000001/exportTemplate?api-version=2019-07-01 + response: + body: + string: '{"template":{"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion":"1.0.0.0","parameters":{},"variables":{},"resources":[{"type":"Microsoft.Network/virtualNetworks","apiVersion":"2020-04-01","name":"vnet1","location":"westus","tags":{"costCenter":"Contoso/IT/PROD/123456"},"properties":{"addressSpace":{"addressPrefixes":["10.0.0.0/16"]},"dhcpOptions":{"dnsServers":[]},"subnets":[],"virtualNetworkPeerings":[],"enableDdosProtection":false,"enableVmProtection":false}}]}}' + headers: + cache-control: + - no-cache + content-length: + - '526' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 May 2020 18:17:27 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py index 8524cf6fdfa..54d9a57d55d 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py @@ -55,6 +55,32 @@ def test_resource_group(self, resource_group): self.assertEqual('"1.0.0.0"\n', result.output) + @ResourceGroupPreparer(name_prefix='cli_test_rg_scenario') + def test_resource_group_export_skip_all_params(self, resource_group): + + self.kwargs.update({ + 'vnet': 'vnet1' + }) + + self.cmd('network vnet create -g {rg} -n {vnet}') + self.kwargs['vnet_id'] = self.cmd('network vnet show -g {rg} -n {vnet}').get_output_in_json()['id'] + result = self.cmd('group export --name {rg} --resource-ids "{vnet_id}" --skip-all-params --query "parameters"') + + self.assertEqual('{}\n', result.output) + + @ResourceGroupPreparer(name_prefix='cli_test_rg_scenario') + def test_resource_group_export_skip_resource_name_params(self, resource_group): + + self.kwargs.update({ + 'vnet': 'vnet1' + }) + + self.cmd('network vnet create -g {rg} -n {vnet}') + self.kwargs['vnet_id'] = self.cmd('network vnet show -g {rg} -n {vnet}').get_output_in_json()['id'] + result = self.cmd('group export --name {rg} --resource-ids "{vnet_id}" --skip-resource-name-params --query "parameters"') + + self.assertEqual('{}\n', result.output) + class ResourceGroupNoWaitScenarioTest(ScenarioTest):