Add-AzureAccount

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Add-AzureAccount

Adds the Azure account to Windows PowerShell

Syntax

Parameter Set: Default
Add-AzureAccount [-Environment <String> ] [-SubscriptionDataFile <String> ] [ <CommonParameters>]

Detailed 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" (https://azure.microsoft.com/en-us/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.1 version of the Microsoft Azure PowerShell module. To find out the version of the module you're using, from the Azure PowerShell console, type (get-module azure).version.

Parameters

-Environment<String>

Specifies an Azure environment for the user account. This parameter is optional. The default is the AzureCloud 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.

To get the available Azure environments, use the Get-AzureEnvironment cmdlet. To add an environment, use the Add-AzureEnvironment cmdlet.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SubscriptionDataFile<String>

Specifies an alternate location for the subscription data file. This parameter is optional. By default, the subscription data file is saved in your roaming user profile.

If you use this parameter to specify an alternate location for the subscription data file, be sure to use the SubscriptionDataFile parameters of cmdlets that access your account. Otherwise, the cmdlets look for your account data in the default location.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

    You cannot pipe input to this cmdlet

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

    This cmdlet does not return any output.

Notes

  • Add-AzureAccount (and the Azure AD authentication method) takes precedence over Import-AzurePublishSettings (and the management certificate method). If you use Add-AzureAccount even once on your account, the Azure AD authentication method is used and the management certificate is ignored. To remove the Azure AD token and restore the management certificate method, use the Remove-AzureAccount cmdlet. For more information, type: Get-Help Remove-AzureAccount.

  • The error, "Your credentials have expired. Please use Add-AzureAccount to log in again." indicates that your access token is expired and Windows PowerShell cannot access your Azure account. To restore access to your account, run Add-AzureAccount again.

  • The Azure PowerShell account and subscription cmdlets get their data from the subscription data file, not from the live Azure account. If you change your account or subscriptions outside of Windows PowerShell, such as by using the Azure Management Portal, run Add-AzureAccount again to refresh the subscription data file.

Examples

---------- Example 1: Add an account ----------

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.

PS C:\> Add-AzureAccount

---------- Example 2: Use an alternate subscription data file ----------

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.

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

Add-AzureEnvironment

Get-AzureEnvironment

Import-AzurePublishSettingsFile

Get-AzureAccount

Remove-AzureAccount