|
1 | 1 | ---
|
2 | 2 | title: Migrate SQL server
|
3 |
| -description: Document listing how to migrate the Azure App Service on Azure Stack Hub resource provider SQL server. |
4 |
| -author: apwestgarth |
5 |
| -manager: stefsch |
6 |
| - |
| 3 | +description: Learn how to migrate the Azure App Service on the Azure Stack Hub Resource Provider to SQL server. |
| 4 | +author: sethmanheim |
7 | 5 | ms.topic: article
|
8 |
| -ms.date: 10/25/2022 |
9 |
| -ms.author: anwestg |
10 |
| -ms.reviewer: |
11 |
| -ms.lastreviewed: |
12 |
| - |
13 |
| -# Intent: Notdone: As a < type of user >, I want < what? > so that < why? > |
14 |
| -# Keyword: Notdone: keyword noun phrase |
15 |
| - |
16 |
| ---- |
| 6 | +ms.date: 08/12/2024 |
| 7 | +ms.author: sethm |
| 8 | +ms.reviewer: anwestg |
17 | 9 |
|
18 | 10 | ---
|
19 | 11 |
|
20 | 12 | # Migrate SQL server
|
21 | 13 |
|
22 |
| -This article describes how to migrate to new SQL Server infrastructure for hosting the Azure App Service on Azure Stack Hub Resource Provider databases - appservice_hosting and appservice_metrics. |
23 |
| - |
| 14 | +This article describes how to migrate to the SQL Server infrastructure for hosting the Azure App Service on Azure Stack Hub Resource Provider databases, including appservice_hosting and appservice_metrics. |
24 | 15 |
|
25 | 16 | ## Back up App Service secrets
|
26 |
| -When preparing to migrate, you must back up the App Service keys used by the initial deployment. |
27 |
| - |
28 | 17 |
|
29 |
| -Use the administration portal to back up app service secrets by following these steps: |
| 18 | +When you prepare to migrate, you must back up the App Service keys used by the initial deployment. Use the administrator portal to back up App Service secrets by following these steps: |
30 | 19 |
|
31 | 20 | 1. Sign in to the Azure Stack Hub administrator portal as the service admin.
|
32 |
| - |
33 |
| -2. Browse to **App Service** -> **Secrets**. |
34 |
| - |
35 |
| -3. Select **Download Secrets**. |
| 21 | +1. Browse to **App Service** -> **Secrets**. |
| 22 | +1. Select **Download Secrets**. |
36 | 23 |
|
37 | 24 | 
|
38 | 25 |
|
39 |
| -4. When secrets are ready for downloading, click **Save** and store the App Service secrets (**SystemSecrets.JSON**) file in a safe location. |
| 26 | +1. When the secrets are ready for downloading, select **Save** and store the App Service secrets (**SystemSecrets.JSON**) file in a safe location. |
40 | 27 |
|
41 | 28 | 
|
42 | 29 |
|
43 | 30 | ## Back up the App Service databases from the current server
|
44 | 31 |
|
| 32 | +To restore App Service, you need the **Appservice_hosting** and **Appservice_metering** database backups. We recommend using SQL Server maintenance plans or Azure Backup Server to ensure these databases are backed up and saved securely regularly. However, you can use any method that ensures regular SQL database backups are created. |
45 | 33 |
|
46 |
| -To restore App Service, you need the **Appservice_hosting** and **Appservice_metering** database backups. We recommend using SQL Server maintenance plans or Azure Backup Server to ensure these databases are backed up and saved securely regularly. However, any methods of ensuring regular SQL database backups are created can be used. |
| 34 | +To manually back up these databases while logged into SQL Server, use the following PowerShell commands: |
47 | 35 |
|
48 |
| -To manually back up these databases while logged into the SQL Server, use the following PowerShell commands: |
49 |
| - |
50 |
| - ```powershell |
51 |
| - $s = "<SQL Server computer name>" |
52 |
| - $u = "<SQL Server login>" |
53 |
| - $p = read-host "Provide the SQL admin password" |
54 |
| - sqlcmd -S $s -U $u -P $p -Q "BACKUP DATABASE appservice_hosting TO DISK = '<path>\hosting.bak'" |
55 |
| - sqlcmd -S $s -U $u -P $p -Q "BACKUP DATABASE appservice_metering TO DISK = '<path>\metering.bak'" |
56 |
| - ``` |
| 36 | +```powershell |
| 37 | +$s = "<SQL Server computer name>" |
| 38 | +$u = "<SQL Server login>" |
| 39 | +$p = read-host "Provide the SQL admin password" |
| 40 | +sqlcmd -S $s -U $u -P $p -Q "BACKUP DATABASE appservice_hosting TO DISK = '<path>\hosting.bak'" |
| 41 | +sqlcmd -S $s -U $u -P $p -Q "BACKUP DATABASE appservice_metering TO DISK = '<path>\metering.bak'" |
| 42 | +``` |
57 | 43 |
|
58 | 44 | > [!NOTE]
|
59 |
| -> If you need to back up SQL AlwaysOn databases, follow [these instructions](/sql/database-engine/availability-groups/windows/configure-backup-on-availability-replicas-sql-server?view=sql-server-2017&preserve-view=true). |
| 45 | +> If you need to back up SQL AlwaysOn databases, [follow these instructions](/sql/database-engine/availability-groups/windows/configure-backup-on-availability-replicas-sql-server?view=sql-server-2017&preserve-view=true). |
60 | 46 |
|
61 |
| -After all databases have been successfully backed up, copy the .bak files to a safe location along with the App Service secrets info. |
| 47 | +After you successfully back up all databases, copy the .bak files to a safe location along with the App Service secrets info. |
62 | 48 |
|
63 | 49 | ## Restore the App Service databases on a new production ready SQL Server instance
|
64 | 50 |
|
65 |
| -The App Service SQL Server databases should be restored on a production ready SQL Server instance. |
| 51 | +The App Service SQL Server databases should be restored on a production-ready SQL Server instance. |
66 | 52 |
|
67 |
| -After [preparing the SQL Server instance](azure-stack-app-service-before-you-get-started.md#prepare-the-sql-server-instance) to host the App Service databases, use these steps to restore databases from backup: |
| 53 | +After you [prepare the SQL Server instance](azure-stack-app-service-before-you-get-started.md#prepare-the-sql-server-instance) to host the App Service databases, use these steps to restore databases from backup: |
68 | 54 |
|
69 | 55 | 1. Sign in to the SQL Server that will host the recovered App Service databases with admin permissions.
|
70 |
| -2. Use the following commands to restore the App Service databases from a command prompt running with admin permissions: |
71 |
| - ```dos |
72 |
| - sqlcmd -U <SQL admin login> -P <SQL admin password> -Q "RESTORE DATABASE appservice_hosting FROM DISK='<full path to backup>' WITH REPLACE" |
73 |
| - sqlcmd -U <SQL admin login> -P <SQL admin password> -Q "RESTORE DATABASE appservice_metering FROM DISK='<full path to backup>' WITH REPLACE" |
74 |
| - ``` |
75 |
| -3. Verify that both App Service databases have been successfully restored and exit SQL Server Management Studio. |
| 56 | +1. Use the following commands to restore the App Service databases from a command prompt running with admin permissions: |
| 57 | + |
| 58 | + ```cmd |
| 59 | + sqlcmd -U <SQL admin login> -P <SQL admin password> -Q "RESTORE DATABASE appservice_hosting FROM DISK='<full path to backup>' WITH REPLACE" |
| 60 | + sqlcmd -U <SQL admin login> -P <SQL admin password> -Q "RESTORE DATABASE appservice_metering FROM DISK='<full path to backup>' WITH REPLACE" |
| 61 | + ``` |
| 62 | + |
| 63 | +1. Verify that both App Service databases were successfully restored, then exit SQL Server Management Studio. |
76 | 64 |
|
77 | 65 | ## Migrate the SQL Server
|
78 | 66 |
|
79 |
| -1. In the Azure Stack Hub admin portal, navigate to **Network Security Groups** and view the **ControllersNSG** Network Security Group. |
| 67 | +1. In the Azure Stack Hub administrator portal, navigate to **Network Security Groups** and view the **ControllersNSG** Network Security Group. |
| 68 | +1. By default, Remote Desktop is disabled for all App Service infrastructure roles. Modify the **Inbound_Rdp_2289** rule action to **Allow** access. |
| 69 | +1. Navigate to the resource group containing the App Service Resource Provider deployment. By default, the resource group is named in the format **AppService.\<region\>**. |
| 70 | +1. Connect to **CN0-VM**. |
| 71 | +1. Open an administrator PowerShell session and run `net stop webfarmservice`. |
| 72 | +1. Repeat steps 3 and 4 for all other controllers. |
| 73 | +1. Return to the **CN0-VM** Remote Desktop session and copy the secrets file to the controller. |
| 74 | +1. In an administrator PowerShell session run: |
80 | 75 |
|
81 |
| -1. By default, remote desktop is disabled to all App Service infrastructure roles. Modify the **Inbound_Rdp_2289** rule action to **Allow** access. |
82 |
| -1. Navigate to the resource group containing the App Service Resource Provider Deployment, by default the resource group is named in with the format, AppService.\<region\> and connect to **CN0-VM**. |
83 |
| -1. Open an Administrator PowerShell session and run **net stop webfarmservice**. |
| 76 | + ```powershell |
| 77 | + Restore-AppServiceStamp -FilePath <local secrets file> -OverrideDatabaseServer <new database server> -CoreBackupFilePath <filepath> |
| 78 | + ``` |
84 | 79 |
|
85 |
| -1. Repeat step 3 and 4 for all other controllers. |
86 |
| -1. Return to **CN0-VM**'s RDP session and copy the secrets file to the controller. |
| 80 | + 1. A prompt appears that confirms the key values. Press **Enter** to continue, or close the PowerShell session to cancel. |
| 81 | +1. Once the cmdlet completes, all worker instances from the custom worker tiers are removed, and those instances are added back in the next step. |
| 82 | +1. In the same PowerShell session or in a new administrative PowerShell session, run the following PowerShell script. The script inspects all the associated Virtual Machine Scale Sets and performs corresponding actions, including adding back the instances of custom worker tiers: |
87 | 83 |
|
88 |
| -1. In an Administrator PowerShell session run |
89 |
| - ```powershell |
90 |
| - Restore-AppServiceStamp -FilePath <local secrets file> -OverrideDatabaseServer <new database server> -CoreBackupFilePath <filepath> |
91 |
| - ``` |
92 |
| - 1. A prompt will appear to confirm the key values, press **Enter** to continue or close the PowerShell session to cancel. |
93 |
| -1. Once the cmdlet completes, **all** worker instances from the custom worker tiers will be removed, and those instances will be added back by the next step |
94 |
| -1. In the same PowerShell session or a new Administrative PowerShell session, run the following PowerShell script. The script will inspect all the Virtual Machine Scale Sets associated and perform corresponding actions including adding back the instances of custom worker tiers: |
95 | 84 | ```powershell
|
96 | 85 | Restore-AppServiceRoles
|
97 | 86 | ```
|
98 |
| -1. In the same, or a new, administrative PowerShell session, run the command **net start webfarmservice**. |
| 87 | + |
| 88 | +1. In the same, or in a new administrative PowerShell session, run the command `net start webfarmservice`. |
99 | 89 | 1. Repeat the previous step for all other controllers.
|
100 |
| -1. In the Azure Stack admin portal, navigate back to the **ControllersNSG** Network Security Group |
| 90 | +1. In the Azure Stack administrator portal, navigate back to the **ControllersNSG** Network Security Group. |
101 | 91 | 1. Modify the **Inbound_Rdp_3389** rule to deny access.
|
102 | 92 |
|
103 | 93 | ## Next steps
|
| 94 | + |
104 | 95 | [Backup App Service on Azure Stack Hub](app-service-back-up.md)
|
105 |
| -[Restore App Service on Azure Stack Hub](app-service-recover.md) |
| 96 | +[Restore App Service on Azure Stack Hub](app-service-recover.md) |
0 commit comments