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
4 changes: 4 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

**ARM**

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

**IoT Central**

* Support app creation/update with the new sku name ST0, ST1, ST2.
Expand Down
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 --id /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Web/sites/{WebApp}
az resource tag --tags vmlist=vm1 --ids /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: 9 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 @@ -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
from azure.cli.core.profiles import ResourceType, get_sdk, get_api_version, AZURE_API_PROFILES

from azure.cli.command_modules.resource._client_factory import (
_resource_client_factory, _resource_policy_client_factory, _resource_lock_client_factory,
Expand Down Expand Up @@ -2142,7 +2142,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']
need_patch_service = ['Microsoft.RecoveryServices/vaults', 'Microsoft.Resources/resourceGroups']

if resource is not None and resource.type in need_patch_service:
parameters = GenericResource(tags=tags)
Expand Down Expand Up @@ -2268,6 +2268,13 @@ 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