清除 Azure Stack Hub 中的门户用户数据

Azure Stack Hub作员可以在 Azure Stack Hub 用户请求时按需清除门户用户数据。 Azure Stack Hub 用户可以通过固定磁贴和更改仪表板布局来自定义门户。 用户还可以更改主题并调整默认语言以匹配个人首选项。

门户用户数据包括 Azure Stack Hub 用户门户中的收藏夹和最近访问的资源。 本文介绍如何清除门户用户数据。

只有在删除用户订阅后,才能删除门户用户设置。

注意

按照本文中的指南作后,某些用户数据仍存在于事件日志的系统部分中。 此数据可以保留几天,直到日志自动滚动更新。

先决条件

注意

如果你尝试从来宾目录(多租户)中删除受邀用户的门户用户信息,必须在该目录中拥有读取权限。 有关详细信息,请参阅本文后面的 CSP 方案

使用用户主体名称清除门户用户数据

此方案假定默认提供程序订阅和用户属于同一目录,或者你对用户所在的目录具有读取访问权限。

在继续之前,请务必从 GitHub 下载最新版本的 Azure Stack Hub 工具

对于此过程,请使用可与 Azure Stack Hub 的管理员资源管理器终结点通信的计算机。

  1. 打开提升的 Windows PowerShell 会话(以管理员身份运行),转到 AzureStack-Tools-az 目录中的根文件夹,并导入所需的 PowerShell 模块:

    Import-Module .\DatacenterIntegration\Portal\PortalUserDataUtilities.psm1
    
  2. 运行以下命令。 请确保将占位符替换为与环境匹配的值:

    ## The following Azure Resource Manager endpoint is for the ASDK. If you are in a multinode environment, contact your operator or service provider to get the endpoint.
    
    $adminARMEndpoint = "https://adminmanagement.local.azurestack.external"
    
    ## Replace the following value with the Azure Stack Hub directory tenant ID.
    $azureStackDirectoryTenantId = "f5025bf2-547f-4b49-9693-6420c1d5e4ca"
    
    ## Replace the following value with the user directory tenant ID.
    $userDirectoryTenantId = " 7ddf3648-9671-47fd-b63d-eecd82ed040e"
    
    ## Replace the following value with name of the user principal whose portal user data is to be cleared.
    $userPrincipalName = "myaccount@contoso.onmicrosoft.com"
    
    Clear-AzsUserDataWithUserPrincipalName -AzsAdminArmEndpoint $adminARMEndpoint `
     -AzsAdminDirectoryTenantId $azureStackDirectoryTenantId `
     -UserPrincipalName $userPrincipalName `
     -DirectoryTenantId $userDirectoryTenantId
    

    注意

    azureStackDirectoryTenantId 是可选的。 如果未指定此值,脚本将在 Azure Stack Hub 中注册的所有租户目录中搜索用户主体名称,然后清除所有匹配用户的门户数据。

清除来宾目录中的门户用户数据

在此方案中,Azure Stack Hub作员无权访问用户所在的来宾目录。 当你是云解决方案提供商(CSP)时,这是一种常见方案。

若要使 Azure Stack Hub 操作员删除门户用户数据,至少需要用户对象 ID。

用户必须查询对象 ID 并将其提供给 Azure Stack Hub作员。 作员无权访问用户所在的目录。

用户检索用户对象 ID

  1. 打开提升的 Windows PowerShell 会话(以管理员身份运行),转到 AzureStack-Tools-az 目录中的根文件夹,然后导入必要的 PowerShell 模块。

    Import-Module .\DatacenterIntegration\Portal\PortalUserDataUtilities.psm1
    
  2. 运行以下命令。 请确保将占位符替换为与环境匹配的值。

    ## The following Azure Resource Manager endpoint is for the ASDK. If you are in a multinode environment, contact your operator or service provider to get the endpoint.
    $userARMEndpoint = "https://management.local.azurestack.external"
    
    ## Replace the following value with the directory tenant ID, which contains the user account.
    $userDirectoryTenantId = "3160cbf5-c227-49dd-8654-86e924c0b72f"
    
    ## Replace the following value with the name of the user principal whose portal user data is to be cleared.
    $userPrincipleName = "myaccount@contoso.onmicrosoft.com"
    
    Get-UserObjectId -DirectoryTenantId $userDirectoryTenantId `
     -AzsArmEndpoint $userARMEndpoint `
     -UserPricinpalName $userPrincipleName
    

    注意

    作为用户,必须向 Azure Stack Hub作员提供用户对象 ID,该 ID 是上一脚本的输出。

Azure Stack Hub 运维人员删除了门户用户数据

以 Azure Stack Hub作员身份接收用户对象 ID 后,运行以下命令以删除门户用户数据:

  1. 打开提升的 Windows PowerShell 会话(以管理员身份运行),转到 AzureStack-Tools-az 目录中的根文件夹,然后导入必要的 PowerShell 模块。

    Import-Module .\DatacenterIntegration\Portal\PortalUserDataUtilities.psm1
    
  2. 运行以下命令,确保调整参数以匹配环境:

    ## The following Azure Resource Manager endpoint is for the ASDK. If you are in a multinode environment, contact your operator or service provider to get the endpoint.
    $AzsAdminARMEndpoint = "https://adminmanagement.local.azurestack.external"
    
    ## Replace the following value with the Azure Stack Hub directory tenant ID.
    $AzsAdminDirectoryTenantId = "f5025bf2-547f-4b49-9693-6420c1d5e4ca"
    
    ## Replace the following value with the directory tenant ID of the user to clear.
    $DirectoryTenantId = "3160cbf5-c227-49dd-8654-86e924c0b72f"
    
    ## Replace the following value with the name of the user principal whose portal user data is to be cleared.
    $userObjectID = "s-1-*******"
    Clear-AzsUserDataWithUserObject -AzsAdminArmEndpoint $AzsAdminARMEndpoint `
     -AzsAdminDirectoryTenantId $AzsAdminDirectoryTenantId `
     -DirectoryTenantID $DirectoryTenantId `
     -UserObjectID $userObjectID `
    

后续步骤