Skip to content

az ts show uses default subscription even when a full resource id is provided #26030

@jurjenoskam

Description

@jurjenoskam

On Azure CLI 2.46.0, az ts show fails when a full resource ID of the template spec is provided and the current subscription ID is not the same as the subscription ID in the full resource ID:

azureuser@Azure:~$ az account show --query id --output tsv
d505ea46-8351-40d5-850f-4c5289c5d57d
azureuser@Azure:~$ az ts show -s /subscriptions/d0ebf23a-e7ee-4e77-b2ea-39f55c9053d2/resourceGroups/rg-assessed-resources-demo/providers/Microsoft.Resources/templateSpecs/vnet --query name --output tsv
(ResourceGroupNotFound) Resource group 'rg-assessed-resources-demo' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'rg-assessed-resources-demo' could not be found.

That template spec does exist, and the full resource ID is correct:

azureuser@Azure:~$ az resource show --ids /subscriptions/d0ebf23a-e7ee-4e77-b2ea-39f55c9053d2/resourceGroups/rg-assessed-resources-demo/providers/Microsoft.Resources/templateSpecs/vnet --query name --output tsv
vnet

A workaround is to add the --subscription parameter to az ts show like so (note that the subscription ID in the full resource ID and the subscription id provided via --subscription are the same):

azureuser@Azure:~$ az ts show -s /subscriptions/d0ebf23a-e7ee-4e77-b2ea-39f55c9053d2/resourceGroups/rg-assessed-resources-demo/providers/Microsoft.Resources/templateSpecs/vnet --subscription d0ebf23a-e7ee-4e77-b2ea-39f55c9053d2 --query name --output tsv
vnet

Looking at the output of --debug, it appears the az ts show tries to look in the current subscription even when a fully qualified resource ID is provided:

azureuser@Azure:~$ az account show --query id --output tsv
d505ea46-8351-40d5-850f-4c5289c5d57d
azureuser@Azure:~$ az ts show -s /subscriptions/d0ebf23a-e7ee-4e77-b2ea-39f55c9053d2/resourceGroups/rg-assessed-resources-demo/providers/Microsoft.Resources/templateSpecs/vnet --debug 2>&1 | grep 'Request URL'
DEBUG: cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/d505ea46-8351-40d5-850f-4c5289c5d57d/resourceGroups/rg-assessed-resources-demo/providers/Microsoft.Resources/templateSpecs/vnet?$expand=versions&api-version=2021-05-01'

Could this be fixed, so that providing a fully qualified resource ID to az ts show no longer looks in the current subscription context? Thanks!

Metadata

Metadata

Assignees

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamService AttentionThis issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions