Reading Azure CLI source code

msal

"A picture is worth a thousand words." Good open-source code is often more informative than documentation.

Take Azure CLI as an example. It's a well-written Python application, and if you wonder how this or that command works, you can look at the code.

How does the az command work as an executable if it's just a Python script? Check the az file and other files in the same directory.

Or what does acr login do under the hood? It calls docker login with the right credentials.

One more example: how does az login work? It gets JWT tokens with the help of another open-source library - Microsoft Authentication Library (MSAL). The screenshot shows a minimal example that does the same as az login to obtain a new access token.

I'm not saying documentation is useless. On the contrary, good documentation like this explains the theory and provides best practices and examples rarely available in the source code. Reading both code and documentation is like seeing the full picture. The documentation gives you the roadmap and the "why," while the code shows you the "how" and the implementation details. Together, they provide a deeper understanding and help you bridge theory with practice.