共用方式為


Import-AzContext

從檔案載入 Azure 驗證資訊。

語法

Import-AzContext
      [-Path] <String>
      [-Scope <ContextModificationScope>]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Import-AzContext
      [-AzureContext] <AzureRmProfile>
      [-Scope <ContextModificationScope>]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Import-AzContext Cmdlet 會從檔案載入驗證資訊,以設定 Azure 環境和內容。 您在目前會話中執行的 Cmdlet 會使用此資訊來驗證對 Azure Resource Manager 的要求。

範例

範例 1:從 AzureRmProfile 匯入內容

Import-AzContext -AzContext (Connect-AzAccount)

Account                SubscriptionName TenantId                Environment
-------                ---------------- --------                -----------
azureuser@contoso.com  Subscription1    xxxx-xxxx-xxxx-xxxx     AzureCloud

此範例會從傳遞至 Cmdlet 的 PSAzureProfile 匯入內容。

範例 2:從 JSON 檔案匯入內容

Import-AzContext -Path C:\test.json

Account                SubscriptionName TenantId                Environment
-------                ---------------- --------                -----------
azureuser@contoso.com  Subscription1    xxxx-xxxx-xxxx-xxxx     AzureCloud

此範例會從傳遞至 Cmdlet 的 JSON 檔案中選取內容。 您可以從 Save-AzContext 建立此 JSON 檔案。

參數

-AzureContext

{{Fill AzureContext Description}}

類型:AzureRmProfile
別名:Profile
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-Confirm

在執行 Cmdlet 之前,提示您進行確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

用於與 azure 通訊的認證、租用戶和訂用帳戶

類型:IAzureContextContainer
別名:AzContext, AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Path

使用 Save-AzContext 指定儲存的內容資訊路徑。

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-Scope

判斷內容變更的範圍,例如,變更僅適用於目前進程,或套用至此用戶啟動的所有會話。

類型:ContextModificationScope
接受的值:Process, CurrentUser
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WhatIf

顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。

類型:SwitchParameter
別名:wi
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

AzureRmProfile

String

輸出

PSAzureProfile