Add-AzureAccount

Adds the Azure account to Windows PowerShell.

Syntax

Add-AzureAccount
   [-Environment <String>]
   [-Credential <PSCredential>]
   [-Tenant <String>]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]
Add-AzureAccount
   [-Environment <String>]
   -Credential <PSCredential>
   [-ServicePrincipal]
   -Tenant <String>
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

Description

The Add-AzureAccount cmdlet makes your Azure account and its subscriptions available in Windows PowerShell. It's like logging into your Azure account in Windows PowerShell. To log out of the account, use the Remove-AzureAccount cmdlet.

Add-AzureAccount downloads information about your Azure account and saves it in a subscription data file in your roaming user profile. It also gets an access token that allows Windows PowerShell to access your Azure account on your behalf. When the command completes, you can manage your Azure account in Windows PowerShell.

There are two different ways to make your Azure account available to Windows PowerShell. You can use the Add-AzureAccount cmdlet, which uses Azure Active Directory (Azure AD) authentication access tokens, or Import-AzurePublishSettingsFile, which uses a management certificate. For guidance on which method to use, see How to: Connect to your subscription (http://azure.microsoft.com/documentation/articles/install-configure-powershell/#Connect).

When you run Add-AzureAccount, it displays an interactive window that prompts you to sign into your Azure account. This sign-in is valid until the access token expires. When it expires, cmdlets that require access to your account prompt you to run Add-AzureAccount again.

This topic describes the cmdlet in the 0.8.10 version of the Microsoft Azure PowerShell module. To get the version of the module you're using, in the Azure PowerShell console, type (Get-Module -Name Azure).Version.

Examples

Example 1: Add an account

PS C:\> Add-AzureAccount

This command adds an Azure account to Windows PowerShell. When you run the command, a windows pops up to request the user name and password of the account.

Example 2: Use an alternate subscription data file

PS C:\> Add-AzureAccount -SubscriptionDataFile C:\Testing\SDF.xml

This command uses the SubscriptionDataFile parameter to direct Add-AzureAccount to store the account data in the C:\Testing\SDF.xml file, instead of the default file.

Required Parameters

-ServicePrincipal
Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-Credential
Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Environment

Specifies an Azure environment.

An Azure environment an independent deployment of Microsoft Azure, such as AzureCloud for global Azure and AzureChinaCloud for Azure operated by 21Vianet in China. You can also create on-premises Azure environments by using Azure Pack and the WAPack cmdlets. For more information, see Azure Pack (http://www.microsoft.com/server-cloud/products/windows-azure-pack/default.aspx).

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Type:AzureSMProfile
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Tenant
Type:String
Aliases:TenantId
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

You cannot pipe input to this cmdlet

Outputs

None

This cmdlet does not return any output.

Notes