Azure Stack 上的应用服务恢复App Service recovery on Azure Stack

适用于:Azure Stack 集成系统和 Azure Stack 开发工具包Applies to: Azure Stack integrated systems and Azure Stack Development Kit

本主题提供有关应用服务灾难恢复应采取的操作的说明。This topic provides instructions on what actions to take for App Service disaster recovery.

若要从备份恢复 Azure Stack 上的应用服务,必须执行以下操作:The following actions must be taken to recover App Service on Azure Stack from backup:

  1. 还原应用服务数据库。Restore the App Service databases.
  2. 还原文件服务器共享内容。Restore the file server share content.
  3. 还原应用服务角色和服务。Restore App Service roles and services.

如果使用 Azure Stack 存储来存储函数应用,则还必须执行还原函数应用的步骤。If Azure Stack storage was used for Function Apps storage, then you must also take steps to restore Function Apps.

还原应用服务数据库Restore the App Service databases

应用服务 SQL Server 数据库应在生产就绪的 SQL Server 实例上还原。The App Service SQL Server databases should be restored on a production ready SQL Server instance.

准备好用于托管应用服务数据库的 SQL Server 实例之后,请使用以下步骤从备份还原数据库:After preparing the SQL Server instance to host the App Service databases, use these steps to restore databases from backup:

  1. 使用管理员权限登录到要托管已恢复应用服务数据库的 SQL Server。Sign in to the SQL Server that will host the recovered App Service databases with admin permissions.
  2. 从以管理员权限运行的命令提示符,使用以下命令还原应用服务数据库:Use the following commands to restore the App Service databases from a command prompt running with admin permissions:
    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。Verify that both App Service databases have been successfully restored and exit SQL Server Management Studio.

Note

若要从故障转移群集实例故障中恢复,请参阅从故障转移群集实例故障中恢复To recover from a failover cluster instance failure, see Recover from Failover Cluster Instance Failure.

还原应用服务文件共享内容Restore the App Service file share content

准备好用于托管应用服务文件共享的文件服务器之后,需要从备份还原租户文件共享内容。After preparing the file server to host the App Service file share, you need to restore the tenant file share content from backup. 可以通过任何可用方法将文件复制到新建的应用服务文件共享位置。You can use whatever method you have available to copy the files into the newly created App Service file share location. 在文件服务器上运行此示例会使用 PowerShell 和 Robocopy 连接到远程共享,并将文件复制到共享:Running this example on the file server will use PowerShell and robocopy to connect to a remote share and copy the files to the share:

$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

除了复制文件共享内容以外,还必须重置文件共享本身的权限。In addition to copying the file share contents, you must also reset permissions on the file share itself. 若要重置权限,请在文件服务器计算机上打开管理命令提示符,然后运行 ReACL.cmd 文件。To reset permissions, open an admin command prompt on the file server computer and run the ReACL.cmd file. ReACL.cmd 文件位于 BCDR 目录下的应用服务安装文件中。The ReACL.cmd file is located in the App Service installation files in the BCDR directory.

还原应用服务角色和服务Restore App Service roles and services

还原应用服务数据库和文件共享内容之后,接下来需要使用 PowerShell 还原应用服务角色和服务。After the App Service databases and file share content are restored, you next need to use PowerShell to restore the App Service roles and services. 以下步骤将还原应用服务机密和服务配置。These steps will restore App Service secrets and service configurations.

  1. 使用在应用服务安装期间提供的密码,以 roleadmin 身份登录到应用服务控制器 CN0-VM VM。Log into the App Service controller CN0-VM VM as roleadmin using the password you provided during App Service installation.

    Tip

    需要修改该 VM 的网络安全组,以允许 RDP 连接。You need to modify the VM's network security group to allow RDP connections.

  2. 将本地的 SystemSecrets.JSON 文件复制到控制器 VM。Copy the SystemSecrets.JSON file locally to the controller VM. 在下一步骤中,需要提供此文件的路径作为 $pathToExportedSecretFile 参数。You need to provide the path to this file as the $pathToExportedSecretFile parameter in the next step.

  3. 在权限提升的 PowerShell 控制台窗口中,使用以下命令还原应用服务角色和服务:Use the following commands in an elevated PowerShell console window to restore App Service roles and services:

    # 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 has successfully restarted, and at least one management server is in 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
    

Tip

强烈建议在命令完成时关闭此 PowerShell 会话。It's highly recommended to close this PowerShell session when the command completes.

还原函数应用Restore Function Apps

适用于 Azure Stack 的应用服务不支持还原租户用户应用,或者除文件共享内容以外的数据。App Service for Azure Stack doesn't support restoring tenant user apps or data other than file share content. 必须在应用服务备份和还原操作之外备份和恢复所有其他数据。All other data must be backed up and recovered outside of App Service backup and restore operations. 如果使用 Azure Stack 存储来存储函数应用,则应执行以下步骤来恢复丢失的数据:If Azure Stack storage was used for Function Apps storage, the following steps should be taken to recover lost data:

  1. 创建函数应用使用的新存储帐户。Create a new storage account to be used by the Function App. 此存储可以是 Azure Stack 存储、Azure 存储或任何兼容的存储。This storage can be Azure Stack storage, Azure storage, or any compatible storage.
  2. 检索存储的连接字符串。Retrieve the connection string for the storage.
  3. 打开函数门户,并浏览到该函数应用。Open the function portal and browse to the function app.
  4. 浏览到“平台功能”选项卡,然后单击“应用程序设置”。 Browse to the Platform features tab and click Application Settings.
  5. AzureWebJobsDashboardAzureWebJobsStorage 更改为新的连接字符串,然后单击“保存”。 Change AzureWebJobsDashboard and AzureWebJobsStorage to the new connection string and click Save.
  6. 切换到“概述”。 Switch to Overview.
  7. 重新启动应用。Restart the app. 可能需要多次尝试才能清除所有错误。It might take several tries to clear all errors.

后续步骤Next steps

Azure Stack 中的应用服务概述App Service on Azure Stack overview