Skip to content

Commit 7d30b53

Browse files
committed
fixes
1 parent f8300e7 commit 7d30b53

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

articles/virtual-network/create-peering-different-subscriptions-service-principal.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ If you choose to install and use PowerShell locally, this article requires the A
8787
1. Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup).
8888
8989
```azurepowershell
90-
New-AzResourceGroup -Name test-rg-1 -Location eastus2
90+
$rg = @{
91+
Name = 'test-rg-1'
92+
Location = 'eastus2'}
93+
New-AzResourceGroup @rg
9194
```
9295
9396
1. Use [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork) to create a virtual network named **vnet-1** in **subscription-1**.
@@ -248,7 +251,7 @@ Create **spn1-peer-vnet** with a scope to the virtual network created in the pre
248251
Set-AzureADApplication -ObjectId $app.ObjectId -ReplyUrls $replyURLList -AvailableToOtherTenants $true
249252
```
250253
251-
1. The service principal must have **User.Read.All** permissions to the directory. Use [az ad app permission add](/cli/azure/ad/app#az-ad-app-permission-add) and [az ad app permission grant](/cli/azure/ad/app#az-ad-app-permission-grant) to add the Microsoft Graph permissions of **User.Read.all** to the service principal.
254+
1. The service principal must have **User.Read.All** permissions to the directory. Use [Get-AzureADApplication](/powershell/module/azuread/get-azureadapplication), [Set-AzureADApplication](/powershell/module/azuread/set-azureadapplication), and [New-AzureADUserAppRoleAssignment](/powershell/module/azuread/new-azureaduserapproleassignment) to add the Microsoft Graph permissions of **User.Read.all** to the service principal.
252255
253256
```azurepowershell
254257
# Add permission
@@ -287,7 +290,7 @@ Create **spn1-peer-vnet** with a scope to the virtual network created in the pre
287290
$userReadPermission = $sp.AppRoles | Where-Object {$_.Value -eq 'User.Read.All'}
288291
289292
# Grant the permission
290-
New-AzureADUserAppRoleAssignment -PrincipalId $appid1 -ResourceId $sp.ObjectId -Id $userReadPermission.Id
293+
New-AzureADUserAppRoleAssignment -ObjectId $appid1 -PrincipalId $appid1 -ResourceId $sp.ObjectId -Id $userReadPermission.Id
291294
```
292295
293296
---
@@ -333,7 +336,10 @@ Create **spn1-peer-vnet** with a scope to the virtual network created in the pre
333336
1. Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup).
334337
335338
```azurepowershell
336-
New-AzResourceGroup -Name test-rg-2 -Location westus2
339+
$rg = @{
340+
Name = 'test-rg-2'
341+
Location = 'westus2'}
342+
New-AzResourceGroup @rg
337343
```
338344
339345
1. Use [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork) to create a virtual network named **vnet-1** in **subscription-1**.
@@ -352,7 +358,7 @@ Create **spn1-peer-vnet** with a scope to the virtual network created in the pre
352358
353359
Create a subnet configuration named **subnet-1** with [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig):
354360
355-
```azurepowershell-interactive
361+
```azurepowershell
356362
$subnet = @{
357363
Name = 'subnet-1'
358364
VirtualNetwork = $virtualNetwork
@@ -365,7 +371,7 @@ $subnetConfig = Add-AzVirtualNetworkSubnetConfig @subnet
365371

366372
Write the subnet configuration to the virtual network with [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork).
367373

368-
```azurepowershell-interactive
374+
```azurepowershell
369375
$virtualNetwork | Set-AzVirtualNetwork
370376
```
371377

@@ -495,7 +501,7 @@ Create **spn-2-peer-vnet** with a scope to the virtual network created in the pr
495501
Set-AzureADApplication -ObjectId $app.ObjectId -ReplyUrls $replyURLList -AvailableToOtherTenants $true
496502
```
497503
498-
1. The service principal must have **User.Read.All** permissions to the directory. Use [az ad app permission add](/cli/azure/ad/app#az-ad-app-permission-add) and [az ad app permission grant](/cli/azure/ad/app#az-ad-app-permission-grant) to add the Microsoft Graph permissions of **User.Read.All** to the service principal.
504+
1. The service principal must have **User.Read.All** permissions to the directory. Use [Get-AzureADApplication](/powershell/module/azuread/get-azureadapplication), [Set-AzureADApplication](/powershell/module/azuread/set-azureadapplication), and [New-AzureADUserAppRoleAssignment](/powershell/module/azuread/new-azureaduserapproleassignment) to add the Microsoft Graph permissions of **User.Read.all** to the service principal.
499505
500506
```azurepowershell
501507
# Add permission
@@ -534,7 +540,7 @@ Create **spn-2-peer-vnet** with a scope to the virtual network created in the pr
534540
$userReadPermission = $sp.AppRoles | Where-Object {$_.Value -eq 'User.Read.All'}
535541
536542
# Grant the permission
537-
New-AzureADUserAppRoleAssignment -PrincipalId $appid1 -ResourceId $sp.ObjectId -Id $userReadPermission.Id
543+
New-AzureADUserAppRoleAssignment -PrincipalId $appid2 -ResourceId $sp.ObjectId -Id $userReadPermission.Id
538544
```
539545
540546
---
@@ -549,10 +555,10 @@ An administrator in the **subscription-1** Microsoft Entra ID tenant must approv
549555
550556
# [**Azure CLI**](#tab/create-peering-cli)
551557
552-
1. Use [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) to sign-in to **subscription-2**.
558+
1. Use [az login](/cli/azure/reference-index#az-login) to sign-in to **subscription-2**.
553559
554-
```azurepowershell
555-
Connect-AzAccount
560+
```azurecli
561+
az login
556562
```
557563
558564
1. Use [az ad sp list](/cli/azure/ad/sp#az-ad-sp-list) to obtain the appId of **spn-2-peer-vnet**. Note the appID in the output. This appID is used in the authentication URL in the later steps.
@@ -583,12 +589,12 @@ An administrator in the **subscription-1** Microsoft Entra ID tenant must approv
583589
584590
# [**PowerShell**](#tab/create-peering-powershell)
585591
586-
1. [az login](/cli/azure/reference-index#az-login) to sign-in to **subscription-2**.
592+
1. Use [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) to sign-in to **subscription-2**.
587593
588-
```azurecli
589-
az login
594+
```azurepowershell
595+
Connect-AzAccount
590596
```
591-
597+
592598
1. Use [az ad sp list](/cli/azure/ad/sp#az-ad-sp-list) to obtain the appId of **spn-2-peer-vnet**. Note the appID in the output. This appID is used in the authentication URL in the later steps.
593599
594600
```azurecli
@@ -599,7 +605,7 @@ An administrator in the **subscription-1** Microsoft Entra ID tenant must approv
599605
echo $appid2
600606
```
601607
602-
1. Use the appid for **spn-2-peer-vnet** and the Microsoft Entra ID tenant ID for **subcription-1** to build the sign-in URL for the approval. The URL is built from the following example:
608+
1. Use the appid for **spn-2-peer-vnet** and the Microsoft Entra ID tenant ID for **subscription-1** to build the sign-in URL for the approval. The URL is built from the following example:
603609
604610
```
605611
https://login.microsoftonline.com/entra-tenant-id-subscription-1/oauth2/authorize?client_id={$appid2}&response_type=code&redirect_uri=https://www.microsoft.com

0 commit comments

Comments
 (0)