Azure PowerShell supports multiple login methods. The simplest way to get started is to log in interactively at the command line.
Interactive log in
Login-AzureRmAccount. You will get dialog box asking for your Azure credentials.
Type the email address and password associated with your account. Azure authenticates and saves the credential information, and then closes the window.
Log in with a service principal
The recommended approach is to use service principals, which provide a way for you to create non-interactive accounts that you can use to manipulate resources. Service principals are like user accounts to which you can apply rules using Azure Active Directory. By granting the minimum permissions needed to a service principal, you can ensure your automation scripts are even more secure.
If you don't already have a service principal, create one.
Log in with the service principal.
Login-AzureRmAccount -ServicePrincipal -ApplicationId "http://my-app" -Credential $pscredential -TenantId $tenantid
To get your TenantId, log in interactively and then get the TenantId from your subscription.
Environment : AzureCloud Account : email@example.com TenantId : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX SubscriptionId : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX SubscriptionName : My Production Subscription CurrentStorageAccount :
Learn more about managing Azure role-based access
For more information about authentication and subscription management in Azure, see Manage Accounts, Subscriptions, and Administrative Roles.
Azure PowerShell cmdlets for role management