Skip to content

A much simpler way to connect to Azure using PowerShell, PowerShell ISE or VSCode.

Notifications You must be signed in to change notification settings

RichShillingtonMSFT/azure-login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

azure-login

If you use PowerShell to interact with Azure, this will make connecting and authenticating to Azure much easier.

I work with PowerShell everyday mostly automating Azure workloads. I find myself constantly logging in to different Azure Subscriptions and Tenants to perform tests or to grab information.

To make my life easier, I load this function in my PowerShell profile by default when PowerShell or VSCode is launched.

Now, instead of having to use 10 different commands to specify an environment, connect to Azure, set my working Subscription, get the SubscriptionID and TenantID and choose my location, I can do this all with one command.

AzLogin - if I am working with Az modules.

ARMLogin - if I am working with AzureRM modules.

This works with PowerShell Console, PowerShell ISE & VSCode.

To set this up, create a folder and save the AzureLoginFunctions.ps1 file from this repository in it.
Example: C:\Users\[ProfileDirectory]\Documents\PowerShellFunctions
You can place other functions or scripts in this directory as well if you want them to load each time you launch PowerShell.

Using the list below, decide how you want the profile to load and for which users.
Download a copy of the corresponding sample profile .ps1 script and place it in that location.
Modify the $FunctionDirectory variable to match the location you picked for your scripts.

All Users All Hosts - C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
All Users ISE Only - C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1
All Users Console Only - C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
All Users VSCode Only - C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.VSCode_profile.ps1

Current User All Hosts - C:\Users\[ProfileDir]\Documents\WindowsPowerShell\profile.ps1
Current User ISE Only - C:\Users\[ProfileDir]\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
Current User Console Only - C:\Users\[ProfileDir]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Current User VSCode Only - C:\Users\[ProfileDir]\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1

That’s all you need to do. Now when you open PowerShell, the AzLogin and ARMLogin functions will load for you. If you want to connect to Azure, just type AzLogin or ARMLogin and hit enter.

After the login function completes, it will populate new variables in your session.
$Environment, $Subscription, $SubscriptionID, $TenantID, $Location

If you want to see it in action, check out the Screen Shots folder in this repository.

About

A much simpler way to connect to Azure using PowerShell, PowerShell ISE or VSCode.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published