Import-AzureRmContext

Loads Azure authentication information from a file.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

Import-AzureRmContext
      [-AzureContext] <AzureRmProfile>
      [-WhatIf]
      [-Confirm]
Import-AzureRmContext
      [-Path] <String>
      [-WhatIf]
      [-Confirm]

Description

The Import-AzureRmContext cmdlet loads authentication information from a file to set the Azure environment and context. Cmdlets that you run in the current session use this information to authenticate requests to Azure Resource Manager.

Examples

Example 1: Importing a context from a AzureRmProfile

PS C:\> Import-AzureRmContext -AzureContext (Add-AzureRmAccount)

Environment           : AzureCloud
Account               : test@outlook.com
TenantId              : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SubscriptionId        : yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
SubscriptionName      : Test Subscription
CurrentStorageAccount :

This example imports a context from a PSAzureProfile that is passed through to the cmdlet.

Example 2: Importing a context from a JSON file

PS C:\> Import-AzureRmContext -Path C:\test.json

Environment           : AzureCloud
Account               : test@outlook.com
TenantId              : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SubscriptionId        : yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
SubscriptionName      : Test Subscription
CurrentStorageAccount :

This example selects a context from a JSON file that is passed through to the cmdlet. This JSON file can be created from Import-AzureRmContext.

Parameters

-AzureContext

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

Type:AzureRmProfile
Aliases:Profile
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

Specifies the path to context information saved by using Save-AzureRMContext.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.Azure.Commands.Common.Authentication.Models.AzureRMProfile

System.String

Outputs

PSAzureProfile