Azure Stack Hub 上的应用程序服务恢复

本文提供有关针对应用程序服务灾难恢复执行哪些操作的说明。

若要从备份恢复 Azure Stack Hub 上的应用程序服务,必须执行以下操作:

  1. 还原应用程序服务数据库。
  2. 还原文件服务器共享内容。
  3. 还原应用程序服务角色和服务。

如果使用 Azure Stack Hub 存储来存储函数应用,则还必须执行还原函数应用的步骤。

还原应用程序服务数据库

应用程序服务 SQL Server 数据库应在生产就绪的 SQL Server 实例上还原。

准备 SQL Server 实例来托管应用程序服务数据库后,请使用以下步骤从备份还原数据库:

  1. 使用管理员权限登录到要托管已恢复应用程序服务数据库的 SQL Server。

  2. 从以管理员权限运行的命令提示符,使用以下命令还原应用程序服务数据库:

    sqlcmd -U <SQL admin login> -P <SQL admin password> -Q "RESTORE DATABASE appservice_hosting FROM DISK='<full path to backup>' WITH REPLACE"
    sqlcmd -U <SQL admin login> -P <SQL admin password> -Q "RESTORE DATABASE appservice_metering FROM DISK='<full path to backup>' WITH REPLACE"
    
  3. 验证两个应用程序服务数据库是否均已成功还原,然后退出 SQL Server Management Studio。

注意

若要从故障转移群集实例故障中恢复,请参阅从故障转移群集实例故障中恢复

还原应用程序服务文件共享内容

准备文件服务器以托管应用程序服务文件共享后,必须从备份还原租户文件共享内容。 可以通过任何可用方法将文件复制到新建的应用程序服务文件共享位置。 文件服务器上的此示例使用 PowerShell 和 Robocopy 连接到远程共享,并将文件复制到共享:

$source = "<remote backup storage share location>"
$destination = "<local file share location>"
net use $source /user:<account to use to connect to the remote share in the format of domain\username> *
robocopy /E $source $destination
net use $source /delete

除了复制文件共享内容以外,还必须重置文件共享本身的权限。 要重置权限,请在文件服务器计算机上打开管理员级别的命令提示符,然后运行 ReACL.cmd 文件。 ReACL.cmd 文件位于 BCDR 目录下的应用程序服务安装文件中。

还原应用程序服务角色和服务

还原应用程序服务数据库和文件共享内容后,必须使用 PowerShell 还原应用程序服务角色和服务。 以下步骤可用于还原应用程序服务机密和服务配置:

  1. 使用在应用程序服务安装期间提供的密码,以 roleadmin 身份登录到应用程序服务控制器 CN0-VM VM。

    提示

    必须修改 VM 的网络安全组,才能允许 RDP 连接。

  2. 将本地的 SystemSecrets.JSON 文件复制到控制器 VM。 在下一步中提供此文件的路径作为 $pathToExportedSecretFile 参数。

  3. 在权限提升的 PowerShell 控制台窗口中,使用以下命令还原应用程序服务角色和服务:

    # Stop App Service services on the primary controller VM.
    net stop WebFarmService
    net stop ResourceMetering
    net stop HostingVssService # This service was deprecated in the App Service 1.5 release and is not required after the App Service 1.4 release.
    
    # Restore App Service secrets. Provide the path to the App Service secrets file copied from backup; for example, C:\temp\SystemSecrets.json.
    # Press ENTER when prompted to reconfigure App Service from backup.
    
    # If necessary, use -OverrideDatabaseServer <restored server> with Restore-AppServiceStamp when the restored database server has a different address than backed-up deployment.
    # If necessary, use -OverrideContentShare <restored file share path> with Restore-AppServiceStamp when the restored file share has a different path from backed-up deployment.
    Restore-AppServiceStamp -FilePath $pathToExportedSecretFile 
    
    # Restore App Service roles.
    Restore-AppServiceRoles
    
    # Restart App Service services.
    net start WebFarmService
    net start ResourceMetering
    net start HostingVssService  # This service was deprecated in the App Service 1.5 release and is not required after the App Service 1.4 release.
    
    # After App Service successfully restarts, and at least one management server is in the ready state, synchronize App Service objects to complete the restore.
    # Enter Y when prompted to get all sites and again for all ServerFarm entities.
    Get-AppServiceSite | Sync-AppServiceObject
    Get-AppServiceServerFarm | Sync-AppServiceObject
    

提示

强烈建议在命令完成时关闭此 PowerShell 会话。

还原函数应用

适用于 Azure Stack Hub 的应用程序服务不支持还原租户用户应用,或者除文件共享内容以外的数据。 必须在应用程序服务备份和还原操作之外备份和恢复所有其他数据。 如果使用 Azure Stack Hub 存储来存储函数应用,则应执行以下步骤来恢复丢失的数据:

  1. 创建函数应用使用的新存储帐户。 此存储可以是 Azure Stack Hub 存储、Azure 存储或任何兼容的存储。
  2. 检索存储的连接字符串。
  3. 打开函数门户,并浏览到该函数应用。
  4. 浏览到“平台功能”选项卡,然后选择“应用程序设置”。
  5. AzureWebJobsDashboardAzureWebJobsStorage 更改为新的连接字符串,然后选择“保存”。
  6. 切换到“概述”。
  7. 重新启动应用。 可能需要多次尝试才能清除所有错误。

后续步骤

Azure Stack Hub 上的应用程序服务概述