Skip to content

Commit ef28a0c

Browse files
authored
Added example of using a user managed identity (MicrosoftDocs#1935)
1 parent be7b09b commit ef28a0c

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

docs-conceptual/azps-5.9.0/authenticate-azureps.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Sign in with Azure PowerShell
33
description: How to sign in with Azure PowerShell as a user, service principal, or with managed identities for Azure resources.
44
ms.devlang: powershell
55
ms.topic: conceptual
6-
ms.date: 09/27/2021
6+
ms.date: 10/18/2021
77
ms.custom: devx-track-azurepowershell
88
ms.service: azure-powershell
99
---
@@ -160,6 +160,21 @@ that assigned identity.
160160
Connect-AzAccount -Identity
161161
```
162162

163+
This example connects using the Managed Service Identity of myUserAssignedIdentity. It adds the user
164+
assigned identity to the virtual machine, then connects using the ClientId of the user assigned
165+
identity. For more information, see
166+
[Configure managed identities for Azure resources on an Azure VM](/active-directory/managed-identities-azure-resources/qs-configure-powershell-windows-vm).
167+
168+
```azurepowershell-interactive
169+
$identity = Get-AzUserAssignedIdentity -ResourceGroupName 'myResourceGroup' -Name 'myUserAssignedIdentity'
170+
Get-AzVM -ResourceGroupName contoso -Name testvm | Update-AzVM -IdentityType UserAssigned -IdentityId $identity.Id
171+
Connect-AzAccount -Identity -AccountId $identity.ClientId # Run on the virtual machine
172+
173+
Account SubscriptionName TenantId Environment
174+
------- ---------------- -------- -----------
175+
yyyy-yyyy-yyyy-yyyy Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
176+
```
177+
163178
## Sign in with a non-default tenant or as a Cloud Solution Provider (CSP)
164179

165180
If your account is associated with more than one tenant, sign-in requires the `Tenant` parameter to

docs-conceptual/azps-6.4.0/authenticate-azureps.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Sign in with Azure PowerShell
33
description: How to sign in with Azure PowerShell as a user, service principal, or with managed identities for Azure resources.
44
ms.devlang: powershell
55
ms.topic: conceptual
6-
ms.date: 09/27/2021
6+
ms.date: 10/18/2021
77
ms.custom: devx-track-azurepowershell
88
ms.service: azure-powershell
99
---
@@ -160,6 +160,21 @@ that assigned identity.
160160
Connect-AzAccount -Identity
161161
```
162162

163+
This example connects using the Managed Service Identity of myUserAssignedIdentity. It adds the user
164+
assigned identity to the virtual machine, then connects using the ClientId of the user assigned
165+
identity. For more information, see
166+
[Configure managed identities for Azure resources on an Azure VM](/active-directory/managed-identities-azure-resources/qs-configure-powershell-windows-vm).
167+
168+
```azurepowershell-interactive
169+
$identity = Get-AzUserAssignedIdentity -ResourceGroupName 'myResourceGroup' -Name 'myUserAssignedIdentity'
170+
Get-AzVM -ResourceGroupName contoso -Name testvm | Update-AzVM -IdentityType UserAssigned -IdentityId $identity.Id
171+
Connect-AzAccount -Identity -AccountId $identity.ClientId # Run on the virtual machine
172+
173+
Account SubscriptionName TenantId Environment
174+
------- ---------------- -------- -----------
175+
yyyy-yyyy-yyyy-yyyy Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
176+
```
177+
163178
## Sign in with a non-default tenant or as a Cloud Solution Provider (CSP)
164179

165180
If your account is associated with more than one tenant, sign-in requires the `Tenant` parameter to

docs-conceptual/azps-6.5.0/authenticate-azureps.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Sign in with Azure PowerShell
33
description: How to sign in with Azure PowerShell as a user, service principal, or with managed identities for Azure resources.
44
ms.devlang: powershell
55
ms.topic: conceptual
6-
ms.date: 10/12/2021
6+
ms.date: 10/18/2021
77
ms.custom: devx-track-azurepowershell
88
ms.service: azure-powershell
99
---
@@ -160,6 +160,21 @@ that assigned identity.
160160
Connect-AzAccount -Identity
161161
```
162162

163+
This example connects using the Managed Service Identity of myUserAssignedIdentity. It adds the user
164+
assigned identity to the virtual machine, then connects using the ClientId of the user assigned
165+
identity. For more information, see
166+
[Configure managed identities for Azure resources on an Azure VM](/active-directory/managed-identities-azure-resources/qs-configure-powershell-windows-vm).
167+
168+
```azurepowershell-interactive
169+
$identity = Get-AzUserAssignedIdentity -ResourceGroupName 'myResourceGroup' -Name 'myUserAssignedIdentity'
170+
Get-AzVM -ResourceGroupName contoso -Name testvm | Update-AzVM -IdentityType UserAssigned -IdentityId $identity.Id
171+
Connect-AzAccount -Identity -AccountId $identity.ClientId # Run on the virtual machine
172+
173+
Account SubscriptionName TenantId Environment
174+
------- ---------------- -------- -----------
175+
yyyy-yyyy-yyyy-yyyy Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
176+
```
177+
163178
## Sign in with a non-default tenant or as a Cloud Solution Provider (CSP)
164179

165180
If your account is associated with more than one tenant, sign-in requires the `Tenant` parameter to

0 commit comments

Comments
 (0)