Hello Cloud Marathoners!
I have been getting a strange error on the Azure Bicep Insert functionality on my laptop, while it was working as expected on my work laptop.
Thus, I started to compare Azure Bicep versions and extension plugin versions on VS Code. Even though, both have the same versions, I was getting the following errors:
ChainedTokenCredential failed due to an unhandled exception
“Caught exception fetching resource: The ChainedTokenCredential failed due to an unhandled exception: Azure CLI authentication failed due to an unknown error. See the troubleshooting guide for more information.”

After a couple of hours of troubleshooting, I was getting a different error:
“Caught exception fetching resource: The ChainedTokenCredential failed due to an unhandled exception: Azure PowerShell authentication failed due to an unknown error. See the troubleshooting guide for more information.”

I was not sure what was wrong, and thus I opened a GitHub issue on Azure/Bicep. Link to the issue: https://github.com/Azure/bicep/issues/9911
Not an Authentication issue
First thing first, I have eliminated the possibility of Azure authentication not working on my VS Code, by running the following commands and seeing the results:

Issues that helped to dig for a fix
I was seeing an error: “The system cannot find the path specified.”. This was in my Windows Command Prompt and PowerShell consoles.
Here are the screenshots of the errors that I was seeing:


Resolving path issues
First, I checked all my paths in Environment Variables on my Windows laptop, and there were 1-2 unresolved paths that I removed.

Cleanup of the Registry AutoRun
The next step was removing any Auto Run values that I may have in Win Registry.
This last step was helpful to resolve all the errors on Windows Command Prompt and PowerShell.

In Summary
At the end of the troubleshooting and after a couple of hours of banging my head into the wall, I was happy that the Path and “ChainedTokenCredential failed” issues had been resolved.
Thank you for reading my post and I hope this post has helped you to troubleshoot the issues that you may have.
If your issue is still not resolved after following my post, please reach back to me.