title | description | services | author | ms.author | manager | ms.product | ms.service | ms.devlang | ms.topic | ms.date |
---|---|---|---|---|---|---|---|---|---|---|
Log in with Azure PowerShell |
Log in with Azure PowerShell |
azure |
sdwheeler |
sewhee |
carmonm |
azure |
azure-powershell |
powershell |
conceptual |
05/15/2017 |
Azure PowerShell supports multiple login methods. The simplest way to get started is to log in interactively at the command line.
-
Type
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.
Service principals 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.
Get-AzureRmSubscription
Environment : AzureCloud Account : [email protected] TenantId : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX SubscriptionId : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX SubscriptionName : My Production Subscription CurrentStorageAccount :
Azure cloud services provide different environments that adhere to the data-handling regulations of various governments. If your Azure account is in one the government clouds, you need to specify the environment when you sign in. For example, if you account is in the China cloud you sign on using the following command:
Login-AzureRmAccount -EnvironmentName AzureChinaCloud
Use the following command to get a list of available environments:
Get-AzureRmEnvironment | Select-Object Name
Name
----
AzureCloud
AzureChinaCloud
AzureUSGovernment
AzureGermanCloud
For more information about authentication and subscription management in Azure, see Manage Accounts, Subscriptions, and Administrative Roles.
Azure PowerShell cmdlets for role management