Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traffic-manager endpoint create ignores subscription argument #24695

Closed
fgendc opened this issue Nov 18, 2022 · 4 comments · Fixed by #26624
Closed

traffic-manager endpoint create ignores subscription argument #24695

fgendc opened this issue Nov 18, 2022 · 4 comments · Fixed by #26624
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request Network az network vnet/lb/nic/dns/etc...
Milestone

Comments

@fgendc
Copy link

fgendc commented Nov 18, 2022

Describe the bug

After updating to azure-cli 2.42.0, using a service principal with access to multiple subscriptions, having SUBSCRIPTION_B as the default the active subscription, and a Traffic Manager in SUBSCRIPTION_A the az traffic-manager endpoint create command fails even when using the --subscription argument.

az login --service-principal \
  -p="$AZURE_CLIENT_SECRET" \
  --tenant "$AZURE_TENANT_ID" \
  --username "$AZURE_CLIENT_ID"

az network traffic-manager endpoint create \
  --name "eastus" \
  --resource-group "us-rg-name" \
  --profile-name "traffic-manager-name" \
  --type externalEndpoints \
  --target "X.X.X.X" \
  --endpoint-location "eastus" \
  --endpoint-status Enabled \
  --subscription "SUBSCRIPTION_A"

Same issue was observed in alpine

Command Name
az network traffic-manager endpoint create

Errors:

(AuthorizationFailed) The client '{client_id}' with object id '{client_id}' does not have authorization to perform action 'Microsoft.Network/trafficmanagerprofiles/externalEndpoints/write' over scope '/subscriptions/SUBSCRIPTION_B/resourceGroups/us-rg-name/providers/Microsoft.Network/trafficmanagerprofiles/traffic-manager-name/externalEndpoints/eastus' or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed
Message: The client '{client_id}' with object id '{client_id}' does not have authorization to perform action 'Microsoft.Network/trafficmanagerprofiles/externalEndpoints/write' over scope '/subscriptions/SUBSCRIPTION_B/resourceGroups/us-rg-name/providers/Microsoft.Network/trafficmanagerprofiles/traffic-manager-name/externalEndpoints/eastus' or the scope is invalid. If access was recently granted, please refresh your credentials.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Update azure-cli to 2.42.0 brew upgrade azure-ci
  • Login with a Service Principal with access to multiple subscription
  • Active subscripton other than the one with the Traffic Manager
  • Create traffic manager endpoint specifying a subscription, as seen in the code snippet above az network traffic-manager endpoint create --name {} --resource-group {} --profile-name {} --type {} --target {} --endpoint-location {} --endpoint-status {} --subscription {}

Expected Behavior

Despite having a different active subscription, command takes the --subscription into account and applies it to the right resource in the right subscription.

Environment Summary

Observed in both macOS and alpine container

macOS-12.6.1-x86_64-i386-64bit, Darwin 21.6.0
Python 3.10.8
Installer: HOMEBREW

azure-cli 2.42.0

Extensions:
azure-firewall 0.12.0
account 0.2.1

Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1
Linux-5.4.0-1078-azure-x86_64-with, Alpine Linux v3.15
Python 3.9.15
Installer: PIP

azure-cli 2.42.0

Additional Context

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. Network az network vnet/lb/nic/dns/etc... labels Nov 18, 2022
@ghost ghost added this to the Backlog milestone Nov 18, 2022
@ghost ghost assigned necusjz Nov 18, 2022
@ghost ghost added Auto-Assign Auto assign by bot Account az login/account labels Nov 18, 2022
@ghost ghost assigned jiasli Nov 18, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Nov 19, 2022

@necusjz for awareness

@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that and removed Account az login/account labels Nov 19, 2022
@yonzhan yonzhan added feature-request and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 12, 2022
@benpearson84
Copy link
Contributor

This is also an issue on az network traffic-manager endpoint list, the active subscription is persisted in the GET request to the Azure API even though a different subscription is being passed into the command. Resulting in a 404 Resource Group Not Found.

Appears to have been introduced in version 2.41, as 2.40 is working as expected.

@ognjengrubac-tomtom
Copy link

Could someone please react on this? We are not able to use latest az cli version in our pipelines for quite some time.

@jsntcy
Copy link
Member

jsntcy commented Jun 5, 2023

@necusjz, could you please help look at the issue?

necusjz added a commit that referenced this issue Jun 8, 2023
…xt (#26624)

* add command context

* re-record test case
avgale pushed a commit to avgale/azure-cli that referenced this issue Aug 24, 2023
…context (Azure#26624)

* add command context

* re-record test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request Network az network vnet/lb/nic/dns/etc...
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants