Skip to content

Commit

Permalink
Revert "[ARM] Fix az resource tag crashed when the parameter --ids pa…
Browse files Browse the repository at this point in the history
…ssed in is resource group ID (#11859)"

This reverts commit 71b52e3.
  • Loading branch information
zhoxing-ms committed Jan 30, 2020
1 parent a92152c commit d21e31f
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 265 deletions.
2 changes: 1 addition & 1 deletion src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Release History
* Azure Stack: surface commands under the profile of 2019-03-01-hybrid

**ARM**
* Fix issue #10246: `az resource tag` crashes when the parameter `--ids` passed in is resource group ID

* Fix issue #11658: `az group export` command does not support `--query` and `--output` parameters
* Fix issue #10279: The exit code of `az group deployment validate` is 0 when the verification fails
* Fix issue #9916: Improve the error message of the conflict between tag and other filter conditions for `az resource list` command
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/resource/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@
az resource tag --tags vmlist=vm1 -g MyResourceGroup -n MyVm --resource-type "Microsoft.Compute/virtualMachines"
- name: Tag a web app with the key 'vmlist' and value 'vm1', using a resource identifier.
text: >
az resource tag --tags vmlist=vm1 --ids /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Web/sites/{WebApp}
az resource tag --tags vmlist=vm1 --id /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Web/sites/{WebApp}
- name: Tag a resource. (autogenerated)
text: az resource tag --ids /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Web/sites/{WebApp} --tags vmlist=vm1
crafted: true
Expand Down
11 changes: 2 additions & 9 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from azure.cli.core.parser import IncorrectUsageError
from azure.cli.core.util import get_file_json, read_file_content, shell_safe_json_parse, sdk_no_wait
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.core.profiles import ResourceType, get_sdk, get_api_version, AZURE_API_PROFILES
from azure.cli.core.profiles import ResourceType, get_sdk, get_api_version

from azure.cli.command_modules.resource._client_factory import (
_resource_client_factory, _resource_policy_client_factory, _resource_lock_client_factory,
Expand Down Expand Up @@ -2161,7 +2161,7 @@ def tag(self, tags):
# please add the service type that needs to be requested with PATCH type here
# for example: the properties of RecoveryServices/vaults must be filled, and a PUT request that passes back
# to properties will fail due to the lack of properties, so the PATCH type should be used
need_patch_service = ['Microsoft.RecoveryServices/vaults', 'Microsoft.Resources/resourceGroups']
need_patch_service = ['Microsoft.RecoveryServices/vaults']

if resource is not None and resource.type in need_patch_service:
parameters = GenericResource(tags=tags)
Expand Down Expand Up @@ -2287,13 +2287,6 @@ def resolve_api_version(rcf, resource_provider_namespace, parent_resource_path,
@staticmethod
def _resolve_api_version_by_id(rcf, resource_id):
parts = parse_resource_id(resource_id)

if len(parts) == 2 and parts['subscription'] is not None and parts['resource_group'] is not None:
return AZURE_API_PROFILES['latest'][ResourceType.MGMT_RESOURCE_RESOURCES]

if 'namespace' not in parts:
raise CLIError('The type of value entered by --ids parameter is not supported.')

namespace = parts.get('child_namespace_1', parts['namespace'])
if parts.get('child_type_2'):
parent = (parts['type'] + '/' + parts['name'] + '/' +
Expand Down
Loading

0 comments on commit d21e31f

Please sign in to comment.