Azure / Azure/bicep

Have better error message when Insert Resource fails if you're not logged in - or prompt for log in

Open
#5,885 0 comments 2 reactions 0 assignees View on GitHub
enhancement error-message
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Is your feature request related to a problem? Please describe.**
Insert Resource may result in a difficult to interpret error message:

```
Caught exception fetching resource: The access token is from the wrong issuer 'https://sts.windows.net/xxx-yyy-zzzz/'. It must match the tenant 'https://sts.windows.net/xxx-yyy-zzzz/' associated with this subscription. Please use the authority (URL) 'https://login.windows.net/xxx-yyy-zzzz' to get the token. Note, if the subscription is transferred to another tenant there is no impact to the services, but information about new tenant could take time to propagate (up to an hour). If you just transferred your subscription and see this error message, please try back later. Status: 401 (Unauthorized) ErrorCode: InvalidAuthenticationTokenTenant Content: {"error":{"code":"InvalidAuthenticationTokenTenant","message":"The access token is from the wrong issuer 'https://sts.windows.net/xxx-yyy-zzzz/'. It must match the tenant 'https://sts.windows.net/xxx-yyy-zzzz/' associa...

```

**Describe the solution you'd like**
Would it be possible to either

1. Have a better error message that indicates that bicep could not get to the sub via one of the three login processes (az cli, powershell or VSCode ext) and an indication on how to log in
2. Have a better error message and a prompt to login via one of the supported methods. It also might be possible to prompt for all three, and then set a bicepconfig.json for the appropriate response.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the Insert Resource flow and how it obtains access through Azure CLI, PowerShell, or the VSCode extension. Define a clearer unauthenticated or tenant-mismatch outcome, with login guidance or a supported prompt, and verify that the resulting behavior distinguishes authentication failures from other resource-fetch errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
authentication, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.