Share via


使用 Azure Resource Manager 範本建立 Microsoft Entra Domain Services 受控網域

Microsoft Entra Domain Services 提供受控網域服務,例如網域加入、組策略、LDAP、Kerberos/NTLM 驗證,與 Windows Server Active Directory 完全相容。 您不需要自行部署、管理和修補網域控制站,就可以使用這些網域服務。 Domain Services 會與您的現有 Microsoft Entra 租使用者整合。 此整合可讓使用者使用其公司認證登入,而且您可以使用現有的群組和使用者帳戶來保護資源的存取權。

本文說明如何使用 Azure Resource Manager 範本建立受控網域。 支持的資源是使用 Azure PowerShell 建立的。

必要條件

若要完成本文,您需要下列資源:

DNS 命名需求

當您建立 Domain Services 受控網域時,您可以指定 DNS 名稱。 當您選擇此 DNS 名稱時,有一些考慮:

  • 內建域名: 根據預設,會使用目錄的內建功能變數名稱( .onmicrosoft.com 後綴)。 如果您想要透過因特網啟用對受控網域的安全 LDAP 存取,您無法建立數位證書來保護使用此預設網域的連線。 Microsoft 擁有 .onmicrosoft.com 網域,因此證書頒發機構單位 (CA) 不會發行憑證。
  • 自定義功能變數名稱: 最常見的方法是指定自定義功能變數名稱,通常是您已經擁有且可路由傳送的功能變數名稱。 當您使用可路由的自訂網域時,流量可以視需要正確流動以支援您的應用程式。
  • 不可路由網域後綴: 我們通常建議您避免不可路由域名後綴,例如 contoso.local.local 後綴無法路由傳送,而且可能會導致 DNS 解析的問題。

提示

如果您建立自定義功能變數名稱,請小心現有的 DNS 命名空間。 建議使用與任何現有 Azure 或內部部署 DNS 名稱空間分開的功能變數名稱。

例如,如果您有現有的 DNS 名稱空間 contoso.com,請使用自定義功能變數名稱建立受控網域 aaddscontoso.com。 如果您需要使用安全 LDAP,您必須註冊並擁有此自定義功能變數名稱,才能產生必要的憑證。

您可能需要為環境中的其他服務建立一些額外的 DNS 記錄,或環境中現有 DNS 名稱空間之間的條件式 DNS 轉寄站。 例如,如果您執行使用根 DNS 名稱裝載網站的 Web 伺服器,可能會發生需要其他 DNS 專案的命名衝突。

在此範例和作法文章中,aaddscontoso.com自定義網域會作為簡短範例使用。 在所有命令中,指定您自己的功能變數名稱。

下列 DNS 名稱限制也適用於:

  • 網域前置詞限制: 您無法建立前置詞超過 15 個字元的受控網域。 指定功能變數名稱的前置詞(例如 aaddscontoso.com 功能變數名稱中的 aaddscontoso)必須包含 15 個字元或更少。
  • 網路名稱衝突: 受控網域的 DNS 功能變數名稱不應已存在於虛擬網路中。 具體來說,請檢查下列會導致名稱衝突的案例。
    • 如果您已經有 Azure 虛擬網路上具有相同 DNS 功能變數名稱的 Active Directory 網域。
    • 如果您打算啟用受控網域的虛擬網路具有與內部部署網路的 VPN 連線。 在此案例中,請確定您的內部部署網路上沒有具有相同 DNS 功能變數名稱的網域。
    • 如果您有 Azure 虛擬網路上具有該名稱的現有 Azure 雲端服務。

建立必要的 Microsoft Entra 資源

Domain Services 需要服務主體和 Microsoft Entra 群組。 這些資源可讓受控網域同步處理數據,並定義哪些使用者具有受控網域中的系統管理許可權。

首先,使用 Register-AzResourceProvider Cmdlet 註冊 Microsoft Entra Domain Services 資源提供者:

Register-AzResourceProvider -ProviderNamespace Microsoft.AAD

使用 New-MgServicePrincipal Cmdlet 建立 Microsoft Entra 服務主體,讓 Domain Services 進行通訊和驗證。 特定應用程式標識符會使用名為 Domain Controller Services 的標識符 為 2565bd9d-da50-47d4-8b85-4c97f669dc36 for Azure Global。 針對其他 Azure 雲端,搜尋 AppId 值 6ba9a5d4-8456-4118-b521-9c5ca10cdf84

New-MgServicePrincipal

現在,使用 New-MgGroup Cmdlet 建立名為 AAD DC 管理員 istratorsMicrosoft Entra 群組。 然後,新增至此群組的使用者會被授與許可權,以在受控網域上執行系統管理工作。

New-MgGroup -DisplayName "AAD DC Administrators" `
  -Description "Delegated group to administer Microsoft Entra Domain Services" `
  -SecurityEnabled:$true -MailEnabled:$false `
  -MailNickName "AADDCAdministrators"

建立 AAD DC 管理員 istrators 群組後,使用 New-MgGroupMember Cmdlet 將使用者新增至群組。 您會先使用 Get-MgGroup Cmdlet 取得 AAD DC 管理員 istrators 群組物件識別符,然後使用 Get-MgUser Cmdlet 取得所需的使用者物件識別符

在下列範例中,具有UPN admin@contoso.onmicrosoft.com之帳戶的用戶物件標識碼。 將此使用者帳戶取代為您想要新增至 AAD DC 管理員 istrators 群組的使用者 UPN:

# First, retrieve the object ID of the newly created 'AAD DC Administrators' group.
$GroupObjectId = Get-MgGroup `
  -Filter "DisplayName eq 'AAD DC Administrators'" | `
  Select-Object Id

# Now, retrieve the object ID of the user you'd like to add to the group.
$UserObjectId = Get-MgUser `
  -Filter "UserPrincipalName eq 'admin@contoso.onmicrosoft.com'" | `
  Select-Object Id

# Add the user to the 'AAD DC Administrators' group.
New-MgGroupMember -GroupId $GroupObjectId.Id -DirectoryObjectId $UserObjectId.Id

最後,使用 New-AzResourceGroup Cmdlet 建立資源群組。 在下列範例中,會在 westus 區域中建立名為 myResourceGroup 的資源群組。 使用您自己的名稱和所需的區域:

New-AzResourceGroup `
  -Name "myResourceGroup" `
  -Location "WestUS"

如果您選擇支援 可用性區域 的區域,網域服務資源會分散到區域以取得更多備援。 「可用性區域」是 Azure 地區內獨特的實體位置。 每個區域都是由一或多個資料中心所組成,配備了獨立的電力、冷卻系統及網路系統。 若要確保復原能力,在所有已啟用的區域中都至少要有三個個別的區域。

您不需要設定網域服務分散到區域。 Azure 平臺會自動處理資源的區域分佈。 如需詳細資訊並查看區域可用性,請參閱什麼是 Azure 中的 可用性區域?

Domain Services 的資源定義

作為 Resource Manager 資源定義的一部分,需要下列組態參數:

參數
domainName 受控網域的 DNS 功能變數名稱,將先前的命名前置詞和衝突點納入考慮。
filteredSync Domain Services 可讓您同步處理 Microsoft Entra ID 中可用的所有使用者和群組,或只同步處理特定群組的範圍

如需範圍同步處理的詳細資訊,請參閱 Microsoft Entra Domain Services 範圍同步處理
notification 設定 如果受控網域中產生任何警示,可以傳送電子郵件通知。

Azure 租使用者的全域管理員和 AAD DC 管理員 istrators 群組的成員可以針對這些通知啟用

如有需要,您可以在有需要注意的警示時,新增通知的其他收件者。
domainConfigurationType 根據預設,受控網域會建立為 使用者 樹系。 這種類型的樹系會同步來自 Microsoft Entra ID 的所有物件,包括在內部部署 AD DS 環境中建立的任何使用者帳戶。 您不需要指定 domainConfiguration 值來建立使用者樹系。

資源樹系只會同步處理直接在 Microsoft Entra 識別碼中建立的使用者和群組。 將值設定為 ResourceTrusting 以建立資源樹系。

如需資源樹系的詳細資訊,包括您可能會使用資源樹系的原因,以及如何使用內部部署 AD DS 網域建立樹系信任,請參閱 Domain Services 資源樹系概觀

下列壓縮參數定義示範如何宣告這些值。 系統會建立名為 aaddscontoso.com 的使用者樹系,並將 Microsoft Entra ID 的所有使用者同步至受控網域:

"parameters": {
    "domainName": {
        "value": "aaddscontoso.com"
    },
    "filteredSync": {
        "value": "Disabled"
    },
    "notificationSettings": {
        "value": {
            "notifyGlobalAdmins": "Enabled",
            "notifyDcAdmins": "Enabled",
            "additionalRecipients": []
        }
    },
    [...]
}

接著會使用下列壓縮的 Resource Manager 範本資源類型來定義和建立受控網域。 Azure 虛擬網路和子網必須已經存在,或建立為 Resource Manager 範本的一部分。 受控網域會連線到此子網。

"resources": [
    {
        "apiVersion": "2017-06-01",
        "type": "Microsoft.AAD/DomainServices",
        "name": "[parameters('domainName')]",
        "location": "[parameters('location')]",
        "dependsOn": [
            "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
        ],
        "properties": {
            "domainName": "[parameters('domainName')]",
            "subnetId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', parameters('vnetName'), '/subnets/', parameters('subnetName'))]",
            "filteredSync": "[parameters('filteredSync')]",
            "notificationSettings": "[parameters('notificationSettings')]"
        }
    },
    [...]
]

這些參數和資源類型可以做為更廣泛 Resource Manager 範本的一部分來部署受控網域,如下一節所示。

使用範例範本建立受控網域

下列完整的 Resource Manager 範例範本會建立受控網域和支援的虛擬網路、子網和網路安全組規則。 需要網路安全組規則來保護受控網域,並確定流量可以正確流動。 系統會建立 DNS 名稱 為 aaddscontoso.com 的使用者樹系,且所有用戶都會從 Microsoft Entra ID 同步處理:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "apiVersion": {
            "value": "2017-06-01"
        },
        "domainConfigurationType": {
            "value": "FullySynced"
        },
        "domainName": {
            "value": "aaddscontoso.com"
        },
        "filteredSync": {
            "value": "Disabled"
        },
        "location": {
            "value": "westus"
        },
        "notificationSettings": {
            "value": {
                "notifyGlobalAdmins": "Enabled",
                "notifyDcAdmins": "Enabled",
                "additionalRecipients": []
            }
        },
        "subnetName": {
            "value": "aadds-subnet"
        },
        "vnetName": {
            "value": "aadds-vnet"
        },
        "vnetAddressPrefixes": {
            "value": [
                "10.1.0.0/24"
            ]
        },
        "subnetAddressPrefix": {
            "value": "10.1.0.0/24"
        },
        "nsgName": {
            "value": "aadds-nsg"
        }
    },
    "resources": [
        {
            "apiVersion": "2017-06-01",
            "type": "Microsoft.AAD/DomainServices",
            "name": "[parameters('domainName')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
            ],
            "properties": {
                "domainName": "[parameters('domainName')]",
                "subnetId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', parameters('vnetName'), '/subnets/', parameters('subnetName'))]",
                "filteredSync": "[parameters('filteredSync')]",
                "domainConfigurationType": "[parameters('domainConfigurationType')]",
                "notificationSettings": "[parameters('notificationSettings')]"
            }
        },
        {
            "type": "Microsoft.Network/NetworkSecurityGroups",
            "name": "[parameters('nsgName')]",
            "location": "[parameters('location')]",
            "properties": {
                "securityRules": [
                    {
                        "name": "AllowSyncWithAzureAD",
                        "properties": {
                            "access": "Allow",
                            "priority": 101,
                            "direction": "Inbound",
                            "protocol": "Tcp",
                            "sourceAddressPrefix": "AzureActiveDirectoryDomainServices",
                            "sourcePortRange": "*",
                            "destinationAddressPrefix": "*",
                            "destinationPortRange": "443"
                        }
                    },
                    {
                        "name": "AllowPSRemoting",
                        "properties": {
                            "access": "Allow",
                            "priority": 301,
                            "direction": "Inbound",
                            "protocol": "Tcp",
                            "sourceAddressPrefix": "AzureActiveDirectoryDomainServices",
                            "sourcePortRange": "*",
                            "destinationAddressPrefix": "*",
                            "destinationPortRange": "5986"
                        }
                    },
                    {
                        "name": "AllowRD",
                        "properties": {
                            "access": "Allow",
                            "priority": 201,
                            "direction": "Inbound",
                            "protocol": "Tcp",
                            "sourceAddressPrefix": "CorpNetSaw",
                            "sourcePortRange": "*",
                            "destinationAddressPrefix": "*",
                            "destinationPortRange": "3389"
                        }
                    }
                ]
            },
            "apiVersion": "2018-04-01"
        },
        {
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[parameters('vnetName')]",
            "location": "[parameters('location')]",
            "apiVersion": "2018-04-01",
            "dependsOn": [
                "[concat('Microsoft.Network/NetworkSecurityGroups/', parameters('nsgName'))]"
            ],
            "properties": {
                "addressSpace": {
                    "addressPrefixes": "[parameters('vnetAddressPrefixes')]"
                },
                "subnets": [
                    {
                        "name": "[parameters('subnetName')]",
                        "properties": {
                            "addressPrefix": "[parameters('subnetAddressPrefix')]",
                            "networkSecurityGroup": {
                                "id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/NetworkSecurityGroups/', parameters('nsgName'))]"
                            }
                        }
                    }
                ]
            }
        }
    ],
    "outputs": {}
}

您可以使用您慣用的部署方法來部署此範本,例如 Microsoft Entra 系統管理中心Azure PowerShell 或 CI/CD 管線。 下列範例使用 New-AzResourceGroupDeployment Cmdlet。 指定您自己的資源群組名稱與樣本檔名稱:

New-AzResourceGroupDeployment -ResourceGroupName "myResourceGroup" -TemplateFile <path-to-template>

建立資源並將控制權傳回 PowerShell 提示字元需要幾分鐘的時間。 受控網域會繼續在背景布建,最多可能需要一小時才能完成部署。 在 Microsoft Entra 系統管理中心,受控網域的 [概觀] 頁面會顯示整個部署階段的目前狀態。

當 Microsoft Entra 系統管理中心顯示受控網域完成布建時,必須完成下列工作:

  • 更新虛擬網路的 DNS 設定,讓虛擬機可以找到網域加入或驗證的受控網域。
    • 若要設定 DNS,請在入口網站中選取您的受控網域。 在 [ 觀] 視窗中,系統會提示您自動設定這些 DNS 設定。
  • 啟用網域服務 的密碼同步處理,讓使用者可以使用其公司認證登入受控網域。

下一步

若要查看受控網域的運作情形,您可以 加入 Windows VM設定安全 LDAP,以及 設定密碼哈希同步