Skip to content

Commit 79a1880

Browse files
author
Michael Bender
committed
updates
1 parent 5105487 commit 79a1880

File tree

1 file changed

+46
-13
lines changed

1 file changed

+46
-13
lines changed

articles/virtual-network-manager/how-to-configure-cross-tenant-powershell.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Configure cross-tenant connection in Azure Virtual Network Manager - PowerShell
3-
description: #Required; article description that is displayed in search results.
3+
description: Learn to connect Azure subscriptions in Azure Virtual Network Manager using cross-tenant connections for the management of virtual networks across subscriptions using Azure PowerShell.
44
author: mbender-ms
55
ms.author: mbender
66
ms.service: virtual-network-manager
@@ -55,51 +55,84 @@ Set-AzContext -TenantId 12345678-12a3-4abc-5cde-678909876543
5555
Select-AzSubscription 87654321-abcd-1234-1def-0987654321ab
5656
5757
#
58-
New-AzNetworkManagerSubscriptionConnection -Name toContosoTenantNM -Description "This connection allows management of the tenant by a central management tenant" -NetworkManagerId "/subscriptions/13579864-1234-5678-abcd-0987654321ab/resourceGroups/$rg.name/providers/Microsoft.Network/networkManagers/"myAVNM""
58+
New-AzNetworkManagerSubscriptionConnection -Name toCentralManagementTenant -Description "This connection allows management of the tenant by a central management tenant" -NetworkManagerId "/subscriptions/13579864-1234-5678-abcd-0987654321ab/resourceGroups/myAVNMResourceGroup/providers/Microsoft.Network/networkManagers/"myAVNM""
5959
6060
#
61-
Get-AzNetworkManagerSubscriptionConnection -Name toContosoTenantNM
61+
Get-AzNetworkManagerSubscriptionConnection -Name toCentralManagementTenant
6262
```
6363

6464
## Verify the connection state is ‘Connected’ (via grid item ‘Status’)
6565

66-
Switch back to the Contoso tenant, and performing a get on the network manager should show the subscription added via the cross tenant scopes property.
66+
Switch back to the central management tenant, and verify the subscription is added to the virtual network manager via the cross tenant scopes property.
6767

6868
```azurepowershell
6969
70-
Get-AzNetworkManager -ResourceGroup $rg.name -Name "myAVN"
70+
Get-AzNetworkManager -ResourceGroup "myAVNMResourceGroup" -Name "myAVNM"
7171
7272
```
7373

7474
## Generate auth tokens for PowerShell
75-
From Azure Portal and Azure CLI we generate the auth tokens needed for the put static member request behind the scenes. Unfortunately, this is not possible (yet) via AVNM’s powershell cmdlets, so the tokens must be generated manually and the request must be sent via the ‘Invoke-RestMethod’ cmdlet
75+
For Azure Portal and Azure CLI, we generate the auth tokens needed for the put static member request behind the scenes. Unfortunately, this is not possible (yet) via AVNM’s pPowershell cmdlets, so the tokens must be generated manually and the request must be sent via the ‘Invoke-RestMethod’ cmdlet
7676

7777

78-
# Get the group you want to add the static members to
79-
$group = Get-AzNetworkManagerGroup -NetworkManagerName "myAVN" -ResourceGroup $rg.name -Name containsCrossTenantResources
78+
### Get the group you want to add the static members to
79+
$group = Get-AzNetworkManagerGroup -NetworkManagerName "myAVN" -ResourceGroup myAVNMResourceGroup -Name containsCrossTenantResources
8080

8181
# Need to be modified
82+
83+
```azurepowershell
84+
8285
$networkManagerTenant = "24680975-1234-abcd-56fg-121314ab5643"
83-
$vnetTenant = "12345678-12a3-4abc-5cde-678909876543"
86+
$targetTenant = "12345678-12a3-4abc-5cde-678909876543"
8487
$staticMemberName = "crossTenantMember"
85-
$vnetResourceId = “/subscriptions/795fe552-a2fc-466a-b436-de4520b73dd2/resourceGroups/temp/providers/Microsoft.Network/virtualNetworks/Vnet1
88+
$targetResourceID = “/subscriptions/87654321-abcd-1234-1def-0987654321ab/resourceGroups/temp/providers/Microsoft.Network/virtualNetworks/targetVnet01
8689
8790
# Everything after this can be copy/pasted
8891
$networkManagerToken = Get-AzAccessToken -TenantId $networkManagerTenant
89-
$vnetToken = Get-AzAccessToken -TenantId $vnetTenant
92+
$targetToken = Get-AzAccessToken -TenantId $targetTenant
9093
9194
$authHeader = @{
9295
'Content-Type'='application/json'
9396
'Authorization'='Bearer ' + $networkManagerToken.Token
94-
'x-ms-authorization-auxiliary'='Bearer ' + $vnetToken.Token
97+
'x-ms-authorization-auxiliary'='Bearer ' + $targetToken.Token
9598
}
9699
97100
$body = (@{
98101
‘properties'= @{
99-
'resourceId'=$vnetResourceId
102+
'resourceId'=$targetResourceID
100103
}
101104
} | ConvertTo-Json)
102105
103106
$restUri = "https://management.azure.com" + $group.Id + "/staticMembers/" + $staticMemberName + "?api-version=2022-01-01"
104107
Invoke-RestMethod -Uri $restUri -Method Put -Headers $authHeader -Body $body
105108
109+
```
110+
111+
## Delete virtual network manager configurations
112+
113+
Now that the virtual network is in the network group, configurations will be applied. To remove the static member or cross-tenant resources, using the commands below:
114+
115+
```azurepowershell
116+
117+
# delete connection on target managed tenant
118+
Remove-AzNetworkManagerScopeConnection -Name ToTargetManagedTenant -ResourceGroup "myAVNMResourceGroup" -NetworkManagerName "myAVNM"
119+
120+
# delete static member group
121+
Remove-AzNetworkManagerStaticMember -Name crossTenantMember -ResourceGroup "myAVNMResourceGroup" -NetworkManagerName "myAVNM"–NetworkGroupName containsCrossTenantResources
122+
123+
# Switch to ‘managed tenant’ if needed
124+
125+
# delete connection on central management tenant
126+
127+
Remove-AzNetworkManagerSubscriptionConnection -Name toCentralManagementTenant
128+
129+
```
130+
## Next steps
131+
132+
> [!div class="nextstepaction"]
133+
134+
- Learn more about [Security admin rules](concept-security-admins.md).
135+
136+
- Learn how to [create a mesh network topology with Azure Virtual Network Manager using the Azure portal](how-to-create-mesh-network.md)
137+
138+
- Check out the [Azure Virtual Network Manager FAQ](faq.md)

0 commit comments

Comments
 (0)