Skip to content

Commit 702e81f

Browse files
authored
Refresh of articles (MicrosoftDocs#1923)
1 parent ca77553 commit 702e81f

19 files changed

+431
-379
lines changed

docs-conceptual/azurermps-6.13.0/authenticate-azureps.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,89 @@
11
---
2-
title: Sign in with Azure PowerShell
3-
description: How to sign in with Azure PowerShell as a user, service principal, or with managed identities for Azure resources.
2+
title: Sign into Azure with the AzureRM PowerShell module
3+
description: How to sign into Azure with the AzureRM PowerShell module as a user, service principal, or with managed identities for Azure resources.
44
ms.devlang: powershell
55
ms.topic: conceptual
6-
ms.date: 09/09/2018
6+
ms.date: 10/05/2021
77
ms.custom: devx-track-azurepowershell
88
---
9-
# Sign in with Azure PowerShell
9+
# Sign into Azure with the AzureRM PowerShell module
1010

1111
[!INCLUDE [migrate-to-az-banner](../../includes/migrate-to-az-banner.md)]
1212

13-
Azure PowerShell supports several authentication methods. The simplest way to get started is to sign in
14-
interactively at the command line.
13+
Azure PowerShell supports several authentication methods. The simplest way to get started is to sign
14+
in interactively at the command line.
1515

1616
## Sign in interactively
1717

18-
To sign in interactively, use the [Connect-AzureRmAccount](/powershell/module/azurerm.profile/connect-azurermaccount) cmdlet.
18+
To sign in interactively, use the
19+
[Connect-AzureRmAccount](/powershell/module/azurerm.profile/connect-azurermaccount) cmdlet.
1920

2021
```azurepowershell-interactive
2122
Connect-AzureRmAccount
2223
```
2324

24-
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.
2527

2628
> [!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
31+
> [Persistent Credentials](context-persistence.md).
2932
3033
## Sign in with a service principal
3134

32-
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.
3438

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).
3641

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.
3848

39-
```azurepowershell-interactive
49+
```azurepowershell
4050
$pscredential = Get-Credential
4151
Connect-AzureRmAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantid
4252
```
4353

4454
## Sign in using an Azure Managed Service Identity
4555

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.
4959

5060
For more information about managed identities for Azure resources, see
5161
[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).
5262

5363
## Sign in as a Cloud Solution Provider (CSP)
5464

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**.
5668

57-
```azurepowershell-interactive
58-
Connect-AzureRmAccount -TenantId 'xxxx-xxxx-xxxx-xxxx'
69+
```azurepowershell
70+
Connect-AzureRmAccount -TenantId '00000000-0000-0000-0000-000000000000'
5971
```
6072

6173
## Sign in to another Cloud
6274

63-
Azure cloud services offer environments compliant with regional data-handling regulations.
64-
For accounts in a regional cloud, set the environment when you sign in with the `-Environment` argument.
75+
Azure cloud services offer environments compliant with regional data-handling regulations. For
76+
accounts in a regional cloud, set the environment when you sign in with the `-Environment` argument.
6577
For example, if your account is in the China cloud:
6678

67-
```azurepowershell-interactive
79+
```azurepowershell
6880
Connect-AzureRmAccount -Environment AzureChinaCloud
6981
```
7082

7183
The following command gets a list of available environments:
7284

73-
```azurepowershell-interactive
74-
Get-AzureRmEnvironment | Select-Object Name
85+
```azurepowershell
86+
Get-AzureRmEnvironment | Select-Object -Property Name
7587
```
7688

7789
## Learn more about managing Azure role-based access

docs-conceptual/azurermps-6.13.0/azureps-vm-tutorial.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
### YamlMime:Tutorial
2-
title: Create virtual machines with the Azure PowerShell
2+
title: Create virtual machines with the AzureRM PowerShell module
33
metadata:
4-
title: Create virtual machines with the Azure PowerShell
5-
description: Get started with Azure PowerShell by creating virtual machines.
4+
title: Create virtual machines with the AzureRM PowerShell module
5+
description: Get started with the AzureRM PowerShell module by creating virtual machines.
66
audience: Developer
77
level: Beginner
88
displayType: two-column
99
interactive: azurepowershell
10-
ms.date: 02/08/2018
11-
ms.author: sttramer
12-
author: sptramer
13-
manager: carmonm
10+
ms.date: 10/05/2021
11+
ms.author: mirobb
12+
author: mikefrobbins
13+
manager: barbkess
1414
ms.devlang: azure-powershell
1515
ms.prod: powershell
1616
ms.technology: azure-powershell
1717
ms.topic: tutorial
18+
ms.custom: devx-track-azurepowershell
1819
clicktale: true
1920
items:
2021
- durationInMinutes: 1

docs-conceptual/azurermps-6.13.0/context-persistence.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Persist user credentials across PowerShell sessions
33
description: Learn how to reuse Azure credentials and other information across multiple PowerShell sessions.
44
ms.devlang: powershell
55
ms.topic: conceptual
6-
ms.date: 09/09/2018
6+
ms.date: 10/05/2021
77
ms.custom: devx-track-azurepowershell
88
---
99
# Persist user credentials across PowerShell sessions
@@ -40,12 +40,14 @@ a new PowerShell session.
4040
## Automatically save the context for the next sign-in
4141

4242
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.
4446

4547
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.
4951

5052
The cmdlets that allow you to manage Azure contexts also allow you fine grained control. If you
5153
want changes to apply only to the current PowerShell session (`Process` scope) or every PowerShell
@@ -64,34 +66,35 @@ two different ways:
6466
Most AzureRM cmdlets allow you to pass the context as a parameter to the cmdlet. You can pass a
6567
context to a background job as shown in the following example:
6668

67-
```powershell-interactive
68-
PS C:\> $job = Start-Job { param ($ctx) New-AzureRmVm -AzureRmContext $ctx [... Additional parameters ...]} -ArgumentList (Get-AzureRmContext)
69+
```powershell
70+
$job = Start-Job { param ($ctx) New-AzureRmVm -AzureRmContext $ctx [... Additional parameters ...]} -ArgumentList (Get-AzureRmContext)
6971
```
7072

7173
- Using the default context with Autosave enabled
7274

7375
If you have enabled **Context Autosave**, background jobs automatically use the default saved
7476
context.
7577

76-
```powershell-interactive
77-
PS C:\> $job = Start-Job { New-AzureRmVm [... Additional parameters ...]}
78+
```powershell
79+
$job = Start-Job { New-AzureRmVm [... Additional parameters ...]}
7880
```
7981

8082
When you need to know the outcome of the background task, use `Get-Job` to check the job status and
8183
`Wait-Job` to wait for the Job to complete. Use `Receive-Job` to capture or display the output of
82-
the background job. For more information, see [about_Jobs](/powershell/module/microsoft.powershell.core/about/about_jobs).
84+
the background job. For more information, see
85+
[about_Jobs](/powershell/module/microsoft.powershell.core/about/about_jobs).
8386

8487
## Creating, selecting, renaming, and removing contexts
8588

86-
To create a context, you must be signed in to Azure. The `Connect-AzureRmAccount` cmdlet (or its alias,
87-
`Login-AzureRmAccount`) sets the default context used by Azure PowerShell cmdlets, and
88-
allows you to access any tenants or subscriptions allowed by your credentials.
89+
To create a context, you must be signed in to Azure. The `Connect-AzureRmAccount` cmdlet (or its
90+
alias, `Login-AzureRmAccount`) sets the default context used by Azure PowerShell cmdlets, and allows
91+
you to access any tenants or subscriptions allowed by your credentials.
8992

9093
To add a new context after sign-in, use `Set-AzureRmContext` (or its alias,
9194
`Select-AzureRmSubscription`).
9295

93-
```azurepowershell-interactive
94-
PS C:\> Set-AzureRMContext -Subscription "Contoso Subscription 1" -Name "Contoso1"
96+
```azurepowershell
97+
Set-AzureRMContext -Subscription 'Contoso Subscription 1' -Name 'Contoso1'
9598
```
9699

97100
The previous example adds a new context targeting 'Contoso Subscription 1' using your current
@@ -100,8 +103,8 @@ default name, using the account ID and subscription ID is used.
100103

101104
To rename an existing context, use the `Rename-AzureRmContext` cmdlet. For example:
102105

103-
```azurepowershell-interactive
104-
PS C:\> Rename-AzureRmContext '[user1@contoso.org; 123456-7890-1234-564321]` 'Contoso2'
106+
```azurepowershell
107+
Rename-AzureRmContext '[user1@contoso.org; 123456-7890-1234-564321]' 'Contoso2'
105108
```
106109

107110
This example renames the context with automatic name `[user1@contoso.org; 123456-7890-1234-564321]`
@@ -110,8 +113,8 @@ to quickly select the context.
110113

111114
Finally, to remove a context, use the `Remove-AzureRmContext` cmdlet. For example:
112115

113-
```azurepowershell-interactive
114-
PS C:\> Remove-AzureRmContext Contoso2
116+
```azurepowershell
117+
Remove-AzureRmContext Contoso2
115118
```
116119

117120
Forgets the context that was named 'Contoso2'. You can recreate this context using
@@ -120,12 +123,12 @@ Forgets the context that was named 'Contoso2'. You can recreate this context usi
120123
## Removing credentials
121124

122125
You can remove all credentials and associated contexts for a user or service principal using
123-
`Disconnect-AzureRmAccount` (also known as `Logout-AzureRmAccount`). When executed without parameters,
124-
the `Disconnect-AzureRmAccount` cmdlet removes all credentials and contexts associated with the User or
125-
Service Principal in the current context. You may pass in a Username, Service Principal Name, or
126-
context to target a particular principal.
126+
`Disconnect-AzureRmAccount` (also known as `Logout-AzureRmAccount`). When executed without
127+
parameters, the `Disconnect-AzureRmAccount` cmdlet removes all credentials and contexts associated
128+
with the User or Service Principal in the current context. You may pass in a Username, Service
129+
Principal Name, or context to target a particular principal.
127130

128-
```azurepowershell-interactive
131+
```azurepowershell
129132
Disconnect-AzureRmAccount user1@contoso.org
130133
```
131134

@@ -134,14 +137,14 @@ Disconnect-AzureRmAccount user1@contoso.org
134137
Occasionally, you may want to select, change, or remove a context in a PowerShell session without
135138
impacting other sessions. To change the default behavior of context cmdlets, use the `Scope`
136139
parameter. The `Process` scope overrides the default behavior by making it apply only for the
137-
current session. Conversely `CurrentUser` scope changes the context in all sessions, instead of
138-
just the current session.
140+
current session. Conversely `CurrentUser` scope changes the context in all sessions, instead of just
141+
the current session.
139142

140143
As an example, to change the default context in the current PowerShell session without impacting
141144
other windows, or the context used the next time a session is opened, use:
142145

143-
```azurepowershell-interactive
144-
PS C:\> Select-AzureRmContext Contoso1 -Scope Process
146+
```azurepowershell
147+
Select-AzureRmContext Contoso1 -Scope Process
145148
```
146149

147150
## How the context autosave setting is remembered
@@ -150,11 +153,11 @@ The context AutoSave setting is saved to the user Azure PowerShell directory
150153
(`%AppData%\Roaming\Windows Azure PowerShell`). Some kinds of computer accounts may not have access
151154
to this directory. For such scenarios, you can use the environment variable
152155

153-
```azurepowershell-interactive
154-
$env:AzureRmContextAutoSave="true" | "false"
156+
```azurepowershell
157+
$env:AzureRmContextAutoSave=$true
155158
```
156159

157-
When set to 'true', the context is automatically saved. If set to 'false', the context isn't saved.
160+
When set to `$true`, the context is automatically saved. If set to `$false`, the context isn't saved.
158161

159162
## Changes to the AzureRM.Profile module
160163

0 commit comments

Comments
 (0)