Import-​Azure​Rm​Context

Loads Azure authentication information from a file.

Syntax

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

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.

Required 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
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Path

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

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
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:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

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

System.String

Outputs

Microsoft.Azure.Commands.Profile.Models.PSAzureProfile