Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Add-AzureAccount

Add-AzureAccount

microsoft.windowsazure.commands.dll, microsoft.windowsazure.commands.profile.dll

Synopsis

Adds the Azure account to Windows PowerShell

Syntax

Add-AzureAccount [-Credential] [-Environment] [-SubscriptionDataFile] [<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" (http://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.

If you have a Microsoft Organizational account, you can use the -Credential parameter to add the subscriptions associated with your account to Windows PowerShell without an interactive dialog.

This topic describes the cmdlet in the .7.2 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

-Credential <PSCredential>

The username and password account credentials used to authenticate with Azure Active Directory. The credentials must be for a Microsoft Organizational account and not another kind of Microsoft account.

Aliases

None

Required?

false

Position

named

Default value

Accept pipeline input?

false

Accept wildcard characters?

false

-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

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

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

None

Return Type

None

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

---------- Example 3: Add a Microsoft Organizational account using -Credential ----------

This command uses the Credential parameter to provide AAD authentication information on the command line, rather than using the pop-up dialog for AAD authentication.

          PS C:\>$credential = Get-Credential
PS C:\>Add-AzureAccount -Credential $credential
        

---------- Example 4: Add an account in Azure China ----------

This command uses the Environment parameter to add an Azure China 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 -Environment AzureChinaCloud
        

Online Version
Add-AzureEnvironment
Get-AzureEnvironment
Import-AzurePublishSettingsFile
Get-AzureAccount
Remove-AzureAccount