You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When run, this cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account. This authentication lasts for the current PowerShell session.
25
+
When run, this cmdlet will bring up a dialog box prompting you for your email address and password
26
+
associated with your Azure account. This authentication lasts for the current PowerShell session.
25
27
26
28
> [!IMPORTANT]
27
-
> As of Azure PowerShell 6.3.0, your credentials are shared among multiple PowerShell sessions as long as you remain
28
-
> signed in to Windows. For more information, see the article on [Persistent Credentials](context-persistence.md).
29
+
> As of Azure PowerShell 6.3.0, your credentials are shared among multiple PowerShell sessions as
30
+
> long as you remain signed in to Windows. For more information, see the article on
Service principals are non-interactive Azure accounts. Like other user accounts, their permissions are managed with Azure Active Directory. By granting a service principal only the permissions it needs, your automation scripts
33
-
stay secure.
35
+
Service principals are non-interactive Azure accounts. Like other user accounts, their permissions
36
+
are managed with Azure Active Directory. By granting a service principal only the permissions it
37
+
needs, your automation scripts stay secure.
34
38
35
-
To learn how to create a service principal for use with Azure PowerShell, see [Create an Azure service principal with Azure PowerShell](create-azure-service-principal-azureps.md).
39
+
To learn how to create a service principal for use with Azure PowerShell, see
40
+
[Create an Azure service principal with Azure PowerShell](create-azure-service-principal-azureps.md).
36
41
37
-
To sign in with a service principal, use the `-ServicePrincipal` argument with the `Connect-AzureRmAccount` cmdlet. You'll also need the service principal's sign-in credentials and the tenant ID associated with the service principal. To get the service principal's credentials as the appropriate object, use the [Get-Credential](/powershell/module/microsoft.powershell.security/get-credential) cmdlet. This cmdlet will display a dialog box to enter the service principal user ID and password into.
42
+
To sign in with a service principal, use the `ServicePrincipal` argument with the
43
+
`Connect-AzureRmAccount` cmdlet. You'll also need the service principal's sign-in credentials and
44
+
the tenant ID associated with the service principal. To get the service principal's credentials as
45
+
the appropriate object, use the
46
+
[Get-Credential](/powershell/module/microsoft.powershell.security/get-credential) cmdlet. This
47
+
cmdlet will display a dialog box to enter the service principal user ID and password into.
## Sign in using an Azure Managed Service Identity
45
55
46
-
Managed identities for Azure resources is a feature of Azure Active Directory. You can use a managed identity
47
-
service principal for sign-in, and acquire an app-only access token to access other resources. Managed identities are only available on
48
-
virtual machines running in an Azure cloud.
56
+
Managed identities for Azure resources is a feature of Azure Active Directory. You can use a managed
57
+
identity service principal for sign-in, and acquire an app-only access token to access other
58
+
resources. Managed identities are only available on virtual machines running in an Azure cloud.
49
59
50
60
For more information about managed identities for Azure resources, see
51
61
[How to use managed identities for Azure resources on an Azure VM to acquire an access token](/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token).
52
62
53
63
## Sign in as a Cloud Solution Provider (CSP)
54
64
55
-
A [Cloud Solution Provider (CSP)](https://azure.microsoft.com/offers/ms-azr-0145p/) sign-in requires the use of `-TenantId`. Normally, this parameter can be provided as either a tenant ID or a domain name. However, for CSP sign-in, it must be provided a **tenant ID**.
65
+
A [Cloud Solution Provider (CSP)](https://azure.microsoft.com/offers/ms-azr-0145p/) sign-in requires
66
+
the use of `TenantId`. Normally, this parameter can be provided as either a tenant ID or a domain
67
+
name. However, for CSP sign-in, it must be provided a **tenant ID**.
Copy file name to clipboardExpand all lines: docs-conceptual/azurermps-6.13.0/context-persistence.md
+34-31Lines changed: 34 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Persist user credentials across PowerShell sessions
3
3
description: Learn how to reuse Azure credentials and other information across multiple PowerShell sessions.
4
4
ms.devlang: powershell
5
5
ms.topic: conceptual
6
-
ms.date: 09/09/2018
6
+
ms.date: 10/05/2021
7
7
ms.custom: devx-track-azurepowershell
8
8
---
9
9
# Persist user credentials across PowerShell sessions
@@ -40,12 +40,14 @@ a new PowerShell session.
40
40
## Automatically save the context for the next sign-in
41
41
42
42
In versions 6.3.0 and later, Azure PowerShell retains your context information automatically between
43
-
sessions. To set PowerShell to forget your context and credentials, use `Disable-AzureRmContextAutoSave`. You'll need to sign in to Azure every time you open a PowerShell session.
43
+
sessions. To set PowerShell to forget your context and credentials, use
44
+
`Disable-AzureRmContextAutoSave`. You'll need to sign in to Azure every time you open a PowerShell
45
+
session.
44
46
45
47
To allow Azure PowerShell to remember your context after the PowerShell session is closed, use
46
-
`Enable-AzureRmContextAutosave`. Context and credential information are automatically saved in
47
-
a special hidden folder in your user directory (`%AppData%\Roaming\Windows Azure PowerShell`).
48
-
Each new PowerShell session targets the context used in your last session.
48
+
`Enable-AzureRmContextAutosave`. Context and credential information are automatically saved in a
49
+
special hidden folder in your user directory (`%AppData%\Roaming\Windows Azure PowerShell`). Each
50
+
new PowerShell session targets the context used in your last session.
49
51
50
52
The cmdlets that allow you to manage Azure contexts also allow you fine grained control. If you
51
53
want changes to apply only to the current PowerShell session (`Process` scope) or every PowerShell
@@ -64,34 +66,35 @@ two different ways:
64
66
Most AzureRM cmdlets allow you to pass the context as a parameter to the cmdlet. You can pass a
65
67
context to a background job as shown in the following example:
0 commit comments