在 Azure Stack Hub 中配置多租户

可以将 Azure Stack Hub 配置为支持来自驻留在其他 Microsoft Entra 目录中的用户的登录,从而允许他们使用 Azure Stack Hub 中的服务。 这些目录与 Azure Stack Hub 目录具有“来宾”关系,被视为来宾Microsoft Entra租户。

例如,考虑以下方案:

  • 你是 contoso.onmicrosoft.com 的服务管理员,Microsoft Entra为 Azure Stack Hub 提供标识和访问管理服务的主租户。
  • Mary 是 adatum.onmicrosoft.com 的目录管理员,来宾Microsoft Entra来宾用户所在的租户。
  • Mary 的公司 (Adatum) 使用你公司提供的 IaaS 和 PaaS 服务。 Adatum 想要让来宾目录 (adatum.onmicrosoft.com) 中的用户能够登录并使用受 contoso.onmicrosoft.com 保护的 Azure Stack Hub 资源。

本指南提供了在这种情况下有关为来宾目录租户在 Azure Stack Hub 中启用或禁用多租户的相关步骤。 你和 Mary 通过注册或取消注册来宾目录租户来完成此过程,这将允许或禁止 Adatum 用户登录 Azure Stack Hub 和使用 Azure Stack Hub 服务。

如果你是云解决方案提供商 (CSP),则可以通过其他方式配置和管理多租户 Azure Stack Hub

先决条件

在注册或注销来宾目录之前,你和 Mary 必须完成各自Microsoft Entra租户的管理步骤:Azure Stack Hub 主目录 (Contoso) ,来宾目录 (Adatum) :

注册来宾目录

若要注册用于多租户的来宾目录,需要配置 Azure Stack Hub 主目录和来宾目录。

配置 Azure Stack Hub 目录

作为 contoso.onmicrosoft.com 的服务管理员,必须先将 Adatum 的来宾目录租户加入 Azure Stack Hub。 以下脚本配置 Azure 资源管理器以接受来自 adatum.onmicrosoft.com 租户中的用户和服务主体的登录:

## The following Azure Resource Manager endpoint is for the ASDK. If you're in a multinode environment, contact your operator or service provider to get the endpoint, formatted as adminmanagement.<region>.<FQDN>.
$adminARMEndpoint = "https://adminmanagement.local.azurestack.external"

## Replace the value below with the Azure Stack Hub directory
$azureStackDirectoryTenant = "contoso.onmicrosoft.com"

## Replace the value below with the guest directory tenant. 
$guestDirectoryTenantToBeOnboarded = "adatum.onmicrosoft.com"

## Replace the value below with the name of the resource group in which the directory tenant registration resource should be created (resource group must already exist).
$ResourceGroupName = "system.local"

## Replace the value below with the region location of the resource group.
$location = "local"

# Subscription Name
$SubscriptionName = "Default Provider Subscription"

Register-AzSGuestDirectoryTenant -AdminResourceManagerEndpoint $adminARMEndpoint `
 -DirectoryTenantName $azureStackDirectoryTenant `
 -GuestDirectoryTenantName $guestDirectoryTenantToBeOnboarded `
 -Location $location `
 -ResourceGroupName $ResourceGroupName `
 -SubscriptionName $SubscriptionName

配置来宾目录

接下来,Mary(Adatum 的目录管理员)必须通过运行以下脚本在 adatum.onmicrosoft.com 来宾目录中注册 Azure Stack Hub:

## The following Azure Resource Manager endpoint is for the ASDK. If you're in a multinode environment, contact your operator or service provider to get the endpoint, formatted as management.<region>.<FQDN>.
$tenantARMEndpoint = "https://management.local.azurestack.external"

## Replace the value below with the guest directory tenant.
$guestDirectoryTenantName = "adatum.onmicrosoft.com"

Register-AzSWithMyDirectoryTenant `
 -TenantResourceManagerEndpoint $tenantARMEndpoint `
 -DirectoryTenantName $guestDirectoryTenantName `
 -Verbose

重要

如果你的 Azure Stack Hub 管理员将来要安装新服务或更新,则你可能需要再次运行此脚本。

随时可以再次运行此脚本来检查目录中的 Azure Stack Hub 应用的状态。

如果在托管磁盘(在 1808 更新中引入)中创建 VM 时发现了问题,则表示已添加新的磁盘资源提供程序,从而需要再次运行此脚本。

指导用户登录

最后,Mary 可以指导具有 @adatum.onmicrosoft.com 帐户的 Adatum 用户通过访问 Azure Stack Hub 用户门户来登录。 对于多节点系统,用户门户 URL 的格式为 https://portal.<region>.<FQDN>。 对于 ASDK 部署,URL 为 https://portal.local.azurestack.external

Mary 还必须指导任何外部主体(Adatum 目录中没有 adatum.onmicrosoft.com 后缀的用户)使用 https://<user-portal-url>/adatum.onmicrosoft.com 登录。 如果他们未在此 URL 中指定 /adatum.onmicrosoft.com 目录租户,则会被发送到其默认目录,并收到一个错误,指出其管理员未同意。

注销来宾目录

如果你不再需要允许从来宾目录租户登录到 Azure Stack Hub 服务,则可以注销该目录。 同样,这需要配置 Azure Stack Hub 主目录和来宾目录:

  1. 以来宾目录的管理员身份(在此场景中为 Mary)运行 Unregister-AzsWithMyDirectoryTenant。 该 cmdlet 从新目录中卸载所有 Azure Stack Hub 应用。

    ## The following Azure Resource Manager endpoint is for the ASDK. If you're in a multinode environment, contact your operator or service provider to get the endpoint, formatted as management.<region>.<FQDN>.
    $tenantARMEndpoint = "https://management.local.azurestack.external"
    
    ## Replace the value below with the guest directory tenant.
    $guestDirectoryTenantName = "adatum.onmicrosoft.com"
    
    Unregister-AzsWithMyDirectoryTenant `
     -TenantResourceManagerEndpoint $tenantARMEndpoint `
     -DirectoryTenantName $guestDirectoryTenantName `
     -Verbose 
    
  2. 作为 Azure Stack Hub 的服务管理员(在此场景中是指你),请运行 Unregister-AzSGuestDirectoryTenant cmdlet:

    ## The following Azure Resource Manager endpoint is for the ASDK. If you're in a multinode environment, contact your operator or service provider to get the endpoint, formatted as adminmanagement.<region>.<FQDN>.
    $adminARMEndpoint = "https://adminmanagement.local.azurestack.external"
    
    ## Replace the value below with the Azure Stack Hub directory
    $azureStackDirectoryTenant = "contoso.onmicrosoft.com"
    
    ## Replace the value below with the guest directory tenant. 
    $guestDirectoryTenantToBeDecommissioned = "adatum.onmicrosoft.com"
    
    ## Replace the value below with the name of the resource group in which the directory tenant resource was created (resource group must already exist).
    $ResourceGroupName = "system.local"
    
    Unregister-AzSGuestDirectoryTenant -AdminResourceManagerEndpoint $adminARMEndpoint `
     -DirectoryTenantName $azureStackDirectoryTenant `
     -GuestDirectoryTenantName $guestDirectoryTenantToBeDecommissioned `
     -ResourceGroupName $ResourceGroupName
    

    警告

    禁用多租户的步骤必须按顺序执行。 如果首先完成步骤 1,则步骤 2 将失败。

检索 Azure Stack Hub 标识运行状况报告

替换 <region><domain><homeDirectoryTenant> 占位符,然后以 Azure Stack Hub 管理员的身份执行以下 cmdlet。


$AdminResourceManagerEndpoint = "https://adminmanagement.<region>.<domain>"
$DirectoryName = "<homeDirectoryTenant>.onmicrosoft.com"
$healthReport = Get-AzsHealthReport -AdminResourceManagerEndpoint $AdminResourceManagerEndpoint -DirectoryTenantName $DirectoryName
Write-Host "Healthy directories: "
$healthReport.directoryTenants | Where status -EQ 'Healthy' | Select -Property tenantName,tenantId,status | ft


Write-Host "Unhealthy directories: "
$healthReport.directoryTenants | Where status -NE 'Healthy' | Select -Property tenantName,tenantId,status | ft

更新Microsoft Entra租户权限

此操作将清除 Azure Stack Hub 中指示目录需要更新的警报。 从 Azurestack-tools-master/identity 文件夹运行以下命令:

Import-Module ..\Identity\AzureStack.Identity.psm1

$adminResourceManagerEndpoint = "https://adminmanagement.<region>.<domain>"

# This is the primary tenant Azure Stack Hub is registered to:
$homeDirectoryTenantName = "<homeDirectoryTenant>.onmicrosoft.com"

Update-AzsHomeDirectoryTenant -AdminResourceManagerEndpoint $adminResourceManagerEndpoint `
   -DirectoryTenantName $homeDirectoryTenantName -Verbose

该脚本会提示你在Microsoft Entra租户上输入管理凭据,需要几分钟才能运行。 运行 cmdlet 后将清除该警报。

此版本不支持基于门户的管理

使用管理员门户的多租户管理仅适用于版本 2102 及更高版本。 使用页面左上角的选择器选择更高版本。

注册来宾目录

若要注册用于多租户的来宾目录,需要配置 Azure Stack Hub 主目录和来宾目录。

配置 Azure Stack Hub 目录

第一步是使 Azure Stack Hub 知道来宾目录。 在此示例中,Mary 的公司 Adatum 的目录名为 adatum.onmicrosoft.com。

  1. 登录到 Azure Stack Hub 管理员门户并转到“所有服务”-“目录”。

    显示目录列表的屏幕截图。

  2. 选择“添加”启动加入过程。 输入来宾目录名称“adatum.onmicrosoft.com”,然后选择“添加”。

    显示如何添加新目录的屏幕截图。

  3. 来宾目录显示在列表视图中,其状态为“未注册”。

    显示处于未注册状态的新来宾目录的屏幕截图。

  4. 只有 Mary 具有对来宾目录进行身份验证的凭据,因此必须向她发送链接以完成注册。 选中“adatum.onmicrosoft.com”复选框,然后选择“注册”。

    显示如何选择要注册的目录的屏幕截图。

  5. 此时会打开新浏览器标签。 选择页面底部的“复制链接”,并将其提供给 Mary。

  6. 如果你有来宾目录的凭据,则可以通过选择“登录”来自行完成注册。

    显示选择“登录”的屏幕截图。

配置来宾目录

Mary 收到了电子邮件,其中包含用于注册目录的链接。 她在浏览器中打开该链接,并确认 azure Stack Hub 系统的Microsoft Entra ID 和 Azure 资源管理器 终结点。

  1. Mary 使用其 adatum.onmicrosoft.com 全局管理员凭据登录。

    注意

    在登录之前,请确保已禁用弹出窗口阻止程序。

    显示如何登录以管理目录的屏幕截图。

  2. Mary 查看目录的状态,看到该目录尚未注册。

    显示未注册的目录的屏幕截图。

  3. Mary 选择“注册”启动注册过程。

    注意

    Visual Studio Code 所需的对象可能无法创建,并且必须使用 PowerShell。

    显示如何启动目录注册的屏幕截图。

  4. 注册过程完成后,Mary 可以查看目录中创建的所有应用程序,并检查其状态。

    显示已注册的目录的屏幕截图。

  5. Mary 已成功完成注册过程,现在可以指导具有 @adatum.onmicrosoft.com 帐户的 Adatum 用户通过访问 Azure Stack Hub 用户门户来登录。 对于多节点系统,用户门户 URL 的格式为 https://portal.<region>.<FQDN>。 对于 ASDK 部署,URL 为 https://portal.local.azurestack.external

重要

最多可能需要一小时,Azure Stack 操作员才会在管理门户中看到目录状态已更新。

Mary 还必须指导任何外部主体(Adatum 目录中没有 adatum.onmicrosoft.com 后缀的用户)使用 https://<user-portal-url>/adatum.onmicrosoft.com 登录。 如果他们未在此 URL 中指定 /adatum.onmicrosoft.com 目录租户,则会被发送到其默认目录,并收到一个错误,指出其管理员未同意。

注销来宾目录

如果你不再需要允许从来宾目录租户登录到 Azure Stack Hub 服务,则可以注销该目录。 同样,这需要配置 Azure Stack Hub 主目录和来宾目录:

配置来宾目录

Mary 不再使用 Azure Stack Hub 上的服务,且必须删除对象。 她再次打开通过电子邮件收到的 URL 以取消注册目录。 在启动此过程之前,Mary 先删除 Azure Stack Hub 订阅中的所有资源。

  1. Mary 使用其 adatum.onmicrosoft.com 全局管理员凭据登录。

    注意

    在登录之前,请确保已禁用弹出窗口阻止程序。

    显示选择“登录”的屏幕截图。

  2. Mary 查看目录的状态。

    显示已注册的目录的屏幕截图。

  3. Mary 选择“取消注册”以启动该操作。

    显示选择“取消注册”以取消注册目录的屏幕截图。

  4. 该过程完成后,状态将显示为“未注册”:

    显示已取消注册的目录的屏幕截图。

    Mary 已成功取消注册目录 adatum.onmicrosoft.com。

    注意

    最多可能需要一小时,该目录才会在 Azure Stack 管理门户中显示为“未注册”。

配置 Azure Stack Hub 目录

作为 Azure Stack Hub 操作员,你随时都可以删除来宾目录,即使 Mary 先前未取消注册该目录。

  1. 登录到 Azure Stack Hub 管理员门户并转到“所有服务”-“目录”。

    显示所有目录的屏幕截图。

  2. 选中“adatum.onmicrosoft.com”目录复选框,然后选择“删除”。

    显示选择某个目录对应的“删除”的屏幕截图。

  3. 键入“是”并选择“删除”以确认删除操作 。

    显示如何删除目录的屏幕截图。

    现已成功删除该目录。

管理所需的更新

Azure Stack Hub 更新可以引入可能需要更新主目录或来宾目录的新工具或服务的支持。

作为 Azure Stack Hub 操作员,你将在管理门户中收到一条警报,告知你需要进行某项目录更新。 还可以通过查看管理门户中的目录窗格来确定是否需要更新主目录或来宾目录。 每个目录列表将显示该目录的类型。 类型可以是主目录或来宾目录,并且其状态会被显示。

更新 Azure Stack Hub 目录

需要进行 Azure Stack Hub 目录更新时,会显示“需要更新”状态。 例如:

显示目录需要更新的屏幕截图。

若要更新目录,请选中“目录名称”复选框,然后选择“更新” 。

更新来宾目录

Azure Stack Hub 操作员还应该通知来宾目录所有者,让他们使用为注册共享的 URL 来更新其目录。 操作员可以重新发送 URL,但无法更改目录。

来宾目录的所有者 Mary 打开她在注册目录时通过电子邮件收到的 URL:

  1. Mary 使用其 adatum.onmicrosoft.com 全局管理员凭据登录。 在登录之前,请确保已禁用弹出窗口阻止程序。

    显示选择“登录”的屏幕截图。

  2. Mary 看到该目录的状态指示需要更新。

  3. Mary 可以使用“更新”操作来更新来宾目录。 最多可能需要一小时,该目录才会在 Azure Stack 管理门户中显示为“已注册”。

其他功能

Azure Stack Hub 操作员可以查看与目录关联的订阅。 此外,每个目录都有一个操作用于直接在 Azure 门户中管理该目录。 若要进行管理,目标目录必须在 Azure 门户中提供管理权限。

后续步骤