When doing automated deployments to Azure, I found that I was missing a single approach for authentication when used both in a release pipeline, and when doing ad hoc testing during development.
I needed something that let me use an Azure Service Principal for automated processes, as well as using my private credentials for other usages.
After many iterations, I think I have something that is worthwhile sharing with others, in the form of simple templates that gives you a kick-start to any Azure project!
For the sake of completeness, I have included code for authenticating to Azure using bash (for those of you that are working in a Linux environment), PowerShell (both using the Azure PowerShell module and Azure CLI v2 for Windows) and even DOS batch format (for those of you who are really old-school and on Windows).
As you see from the code, the two PowerShell templates are the most fleshed out, since PowerShell is what I normally use. In the future I might expand on the bash one, and I also want to do a Python template at one point. In either case, I’ll update this post with the additional code.
Using these should be quite evident, but if you have any questions don’t hesitate to contact me.