Share via


在 Azure 虛擬網絡 Manager 預覽版中設定跨租用戶連線 - CLI

在本文中,您將瞭解如何使用 Azure CLI 在 Azure 虛擬網絡 Manager 中建立跨租用戶連線。 跨租用戶支援可讓組織使用中央網路管理員來管理跨租用戶和訂用帳戶的虛擬網路。

首先,您將在中央網路管理員上建立範圍連線。 然後,您將在連線的租使用者上建立網路管理員連線,並確認連線。 最後,您將從不同的租使用者新增虛擬網路並驗證。 完成所有工作之後,您可以從網路管理員集中管理其他租用戶的資源。

重要

Azure 虛擬網絡 Manager 通常適用於具有安全性系統管理員規則的中樞與輪輻連線設定和安全性設定。 網格聯機設定仍為公開預覽狀態。

此預覽版本是在沒有服務等級協定的情況下提供,不建議用於生產工作負載。 可能不支援特定功能,或可能已經限制功能。 如需詳細資訊,請參閱 Microsoft Azure 預覽版增補使用條款

必要條件

  • 兩個具有您想要透過 Azure 虛擬網絡 Manager 管理的虛擬網路的 Azure 租使用者。 本文參考租使用者,如下所示:
    • 集中管理租用戶:安裝 Azure 虛擬網絡 Manager 實例的租使用者,以及您將從跨租用戶連線集中管理網路群組的位置。
    • 目標受控租使用者:包含要管理的虛擬網路的租使用者。 此租使用者將會連線到中央管理租使用者。
  • 部署在中央管理租使用者中的 Azure 虛擬網絡 Manager。
  • 這些權限:
    • 中央管理租用戶的系統管理員在目標受控租使用者中有來賓帳戶。
    • 系統管理員來賓帳戶具有 在適當範圍層級套用的網路參與者 許可權(管理群組、訂用帳戶或虛擬網路)。

需要設定許可權的協助嗎? 請參閱如何在 Azure 入口網站 中新增來賓使用者,以及如何將使用者角色指派給 Azure 入口網站 中的資源。

在網路管理員內建立範圍連線

範圍連線的建立開始於已部署網路管理員的中央管理租使用者上。 這是您計劃跨租使用者管理所有資源的網路管理員。

在這項工作中,您會設定範圍連線,以從目標租使用者新增訂用帳戶。 您將使用目標網路管理員的訂用帳戶標識碼和租使用者標識碼。 如果您要使用管理群組,請修改 –resource-id 自變數以看起來像 /providers/Microsoft.Management/managementGroups/{mgId}

# Create a scope connection in the network manager in the central management tenant
az network manager scope-connection create --resource-group "myRG" --network-manager-name "myAVNM" --name "ToTargetManagedTenant" --description "This is a connection to manage resources in the target managed tenant" --resource-id "/subscriptions/13579864-1234-5678-abcd-0987654321ab" --tenant-id "24680975-1234-abcd-56fg-121314ab5643"

在另一個租使用者中的訂用帳戶上建立網路管理員連線

建立範圍連線之後,您會切換至網路管理員連線的目標租使用者。 在這項工作中,您會將目標租用戶連線到您先前建立的範圍連線。 您也會驗證連線狀態。

  1. 輸入下列命令,以使用您的系統管理帳戶連線到目標受控租使用者:

    
    # Log in to the target managed tenant
    # Change the --tenant value to the appropriate tenant ID
    az login --tenant "12345678-12a3-4abc-5cde-678909876543"
    

    您必須根據貴組織的原則,完成與組織的驗證。

  2. 輸入下列命令來設定訂用帳戶,並在中央管理租使用者上建立跨租用戶連線。 訂用帳戶與上一個步驟中所參考連線的訂用帳戶相同。

    # Set the Azure subscription
    az account set --subscription 87654321-abcd-1234-1def-0987654321ab
    
    
    # Create a cross-tenant connection to the central management tenant
    az network manager connection subscription create --connection-name "toCentralManagementTenant" --description "This connection allows management of the tenant by a central management tenant" --network-manager-id "/subscriptions/13579864-1234-5678-abcd-0987654321ab/resourceGroups/myRG/providers/Microsoft.Network/networkManagers/myAVNM"
    

確認連線狀態

  1. 輸入下列命令來檢查連線狀態:

    # Check connection status
    az network manager connection subscription show --name "toCentralManagementTenant"
    
  2. 切換回中央管理租使用者。 使用網路 show 管理員的 命令來顯示透過跨租使用者範圍的 屬性新增的訂用帳戶:

    # View the subscription added to the network manager
    az network manager show --resource-group myAVNMResourceGroup --name myAVNM
    

將靜態成員新增至網路群組

在這項工作中,您會使用靜態成員資格,將跨租使用者虛擬網路新增至您的網路群組。 在下列命令中,虛擬網路訂用帳戶與您稍早建立連線時所參考的訂用帳戶相同。

# Create a network group with a static member from the target managed tenant
az network manager group static-member create --network-group-name "CrossTenantNetworkGroup" --network-manager-name "myAVNM" --resource-group "myAVNMResourceGroup" --static-member-name "targetVnet01" --resource-id="/subscriptions/87654321-abcd-1234-1def-0987654321ab
/resourceGroups/myScopeAVNM/providers/Microsoft.Network/virtualNetworks/targetVnet01"

刪除網路管理員設定

既然虛擬網路位於網路群組中,就會套用組態。 若要移除靜態成員或跨租用戶資源,請使用對應的 delete 命令:


# Delete the static member group
az network manager group static-member delete --network-group-name  "CrossTenantNetworkGroup" --network-manager-name " myAVNM" --resource-group "myRG" --static-member-name "targetVnet01” 

# Delete scope connections
az network manager scope-connection delete --resource-group "myRG" --network-manager-name "myAVNM" --name "ToTargetManagedTenant" 

# Switch to a managed tenant if needed 
az network manager connection subscription delete --name "toCentralManagementTenant"  

下一步