Skip to content

Commit 5c0a3d6

Browse files
committed
Addressing PR comments.
1 parent 43f5680 commit 5c0a3d6

File tree

2 files changed

+90
-89
lines changed

2 files changed

+90
-89
lines changed

articles/azure-sql/managed-instance/managed-instance-link-preparation.md

Lines changed: 88 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ If it'sn't SQL Server 2019 CU15 or higher, upgrade your server. SQL Server 2019
5858
Run the following T-SQL on SQL Server to understand if AlwaysOn is enabled.
5959

6060
```sql
61-
-- Is HADR enabled on this SQL Server?
62-
declare @IsHadrEnabled sql_variant = (select SERVERPROPERTY('IsHadrEnabled'))
63-
select
64-
@IsHadrEnabled as IsHadrEnabled,
65-
case @IsHadrEnabled
66-
when 0 then 'The Always On availability groups is disabled.'
67-
when 1 then 'The Always On availability groups is enabled.'
68-
else 'Unknown status.'
69-
end as 'HadrStatus'
61+
-- Is HADR enabled on this SQL Server?
62+
declare @IsHadrEnabled sql_variant = (select SERVERPROPERTY('IsHadrEnabled'))
63+
select
64+
@IsHadrEnabled as IsHadrEnabled,
65+
case @IsHadrEnabled
66+
when 0 then 'The Always On availability groups is disabled.'
67+
when 1 then 'The Always On availability groups is enabled.'
68+
else 'Unknown status.'
69+
end as 'HadrStatus'
7070
```
7171

7272
If AlwaysOn isn't enabled, then you'll need to enable it. You can find official detailed instructions for this process [here](https://docs.microsoft.com/sql/database-engine/availability-groups/windows/enable-and-disable-always-on-availability-groups-sql-server). In the following paragraphs, we'll explain how Always On can be enabled.
@@ -76,7 +76,7 @@ To enable AlwaysOn on a SQL Server, you need to start the **SQL Server Configura
7676
2. Select on the SQL Server Services.
7777
3. Right-select on the SQL Server, then go Properties.
7878

79-
:::image type="content" source="./media/managed-instance-link-preparation/sql-server-configuration-manager-sql-server-properties.png" alt-text="Screenshot showing SQL Server configuration manager.":::
79+
:::image type="content" source="./media/managed-instance-link-preparation/sql-server-configuration-manager-sql-server-properties.png" alt-text="Screenshot showing S Q L Server configuration manager.":::
8080

8181
4. On SQL Server Configuration Manager properties window, select the AlwaysOn High Availability tab.
8282
5. Use the Checkbox to enable AlwaysOn Availability Groups.
@@ -97,21 +97,21 @@ For optimal performance of Manage Instance link feature, it's highly recommended
9797
Detailed official instructions for enabling SQL Server trace flags can be found [here](https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-traceon-transact-sql). In the following paragraphs, we'll describe how traceflags can be set.
9898
Recommended way to enable trace flags, which will persist through the SQL Server restart, is through the SQL Server Configuration Manager.
9999
To enable the trace flags on a SQL Server, follow the steps:
100-
- Start SQL Server Configuration Manager.
101-
- select on the SQL Server Services.
102-
- Right-select on the SQL Server, then go Properties.
103-
:::image type="content" source="./media/managed-instance-link-preparation/sql-server-configuration-manager-sql-server-properties.png" alt-text="Screenshot showing SQL Server configuration manager.":::
104-
- Go to **Startup Parameters** tab.
105-
- Enter trace flag -T1800 and select Add button.
106-
- Enter trace flag -T9567 and select Add button.
107-
- select OK.
100+
1. Start SQL Server Configuration Manager.
101+
2. Select SQL Server Services.
102+
3. Open the SQL Server context menu, then select Properties.
103+
:::image type="content" source="./media/managed-instance-link-preparation/sql-server-configuration-manager-sql-server-properties.png" alt-text="Screenshot showing S Q L Server configuration manager.":::
104+
4. Go to **Startup Parameters** tab.
105+
5. Enter trace flag -T1800 and select Add button.
106+
6. Enter trace flag -T9567 and select Add button.
107+
7. Select OK.
108108

109109
:::image type="content" source="./media/managed-instance-link-preparation/startup-parameters-properties.png" alt-text="Screenshot showing Startup parameter properties.":::
110110

111111
### Restart the SQL Server and validate SQL Server configuration.
112112

113113
After performing the above configuration steps, restart your SQL Server. To do this, go to SQL Server Configuration Manager, right select on the SQL Server, and then go Restart.
114-
:::image type="content" source="./media/managed-instance-link-preparation/sql-server-configuration-manager-sql-server-restart.png" alt-text="Screenshot showing SQL Server restart command call.":::
114+
:::image type="content" source="./media/managed-instance-link-preparation/sql-server-configuration-manager-sql-server-restart.png" alt-text="Screenshot showing S Q L Server restart command call.":::
115115

116116
After the restart use these steps to validate that SQL Server configuration has been successfully completed. With the following T-SQL you'll verify that you're running:
117117
- Supported version of SQL Server
@@ -120,17 +120,17 @@ After the restart use these steps to validate that SQL Server configuration has
120120

121121
Execute the following T-SQL query:
122122
```sql
123-
-- Shows the version and CU of the SQL Server
124-
SELECT @@VERSION
125-
126-
-- Shows if AlwaysOn feature is enabled on SQL Server
127-
SELECT SERVERPROPERTY ('IsHadrEnabled')
128-
129-
-- Lists all trace flags enabled on the SQL Server
130-
DBCC TRACESTATUS
123+
-- Shows the version and CU of the SQL Server
124+
SELECT @@VERSION
125+
126+
-- Shows if AlwaysOn feature is enabled on SQL Server
127+
SELECT SERVERPROPERTY ('IsHadrEnabled')
128+
129+
-- Lists all trace flags enabled on the SQL Server
130+
DBCC TRACESTATUS
131131
```
132132
Below is an example of expected output for SQL Server 2019 with CU15.
133-
:::image type="content" source="./media/managed-instance-link-preparation/ssms-results-expected-outcome.png" alt-text="Screenshot showing expected outcome in SSMS.":::
133+
:::image type="content" source="./media/managed-instance-link-preparation/ssms-results-expected-outcome.png" alt-text="Screenshot showing expected outcome in S S M S.":::
134134

135135
## Enabling network connectivity between SQL Server and Managed Instance
136136

@@ -166,9 +166,8 @@ Here are instructions on how to open the following network ports on both environ
166166

167167
On SQL Server host machine, ports can be allowed in Windows firewall with following PowerShell script.
168168
```powershell
169-
New-NetFirewallRule -DisplayName "Allow TCP port 5022 inbound" -Direction inbound -Profile Any -Action Allow -LocalPort 5022 -Protocol TCP
170-
171-
New-NetFirewallRule -DisplayName "Allow TCP port 5022 outbound" -Direction outbound -Profile Any -Action Allow -LocalPort 5022 -Protocol TCP
169+
New-NetFirewallRule -DisplayName "Allow TCP port 5022 inbound" -Direction inbound -Profile Any -Action Allow -LocalPort 5022 -Protocol TCP
170+
New-NetFirewallRule -DisplayName "Allow TCP port 5022 outbound" -Direction outbound -Profile Any -Action Allow -LocalPort 5022 -Protocol TCP
172171
```
173172

174173
On Azure portal open Network Security Group for the Subnet of the VNet that is hosting the Managed Instance, and there allow inbound and outbound traffic on port 5022.
@@ -183,7 +182,7 @@ Network connectivity through the port 5022 needs to work from SQL Server to Mana
183182
To check if SQL Server can reach Managed Instance use `tnc` command in PowerShell from SQL Server host machine. Replace <ManagedInstanceFQDN> with the fully qualified domain name of Azure SQL Managed Instance.
184183

185184
```powershell
186-
tnc <ManagedInstanceFQDN> -port 5022
185+
tnc <ManagedInstanceFQDN> -port 5022
187186
```
188187

189188
Successful test will show TcpTestSucceeded True.
@@ -200,84 +199,84 @@ To check if Managed Instance can reach SQL Server create a test endpoint and use
200199
Connect to the Managed Instance and execute following T-SQL to create test endpoint.
201200

202201
```sql
203-
-- Create certificate needed for the test endpoint
204-
USE MASTER
205-
CREATE CERTIFICATE TEST_CERT
206-
WITH SUBJECT = N'Certificate for SQL Server',
207-
EXPIRY_DATE = N'3/30/2051'
208-
GO
209-
210-
-- Create test endpoint
211-
USE MASTER
212-
CREATE ENDPOINT TEST_ENDPOINT
213-
STATE=STARTED
214-
AS TCP (LISTENER_PORT=5022, LISTENER_IP = ALL)
215-
FOR DATABASE_MIRRORING (
216-
ROLE=ALL,
217-
AUTHENTICATION = CERTIFICATE TEST_CERT,
218-
ENCRYPTION = REQUIRED ALGORITHM AES
219-
)
202+
-- Create certificate needed for the test endpoint
203+
USE MASTER
204+
CREATE CERTIFICATE TEST_CERT
205+
WITH SUBJECT = N'Certificate for SQL Server',
206+
EXPIRY_DATE = N'3/30/2051'
207+
GO
208+
209+
-- Create test endpoint
210+
USE MASTER
211+
CREATE ENDPOINT TEST_ENDPOINT
212+
STATE=STARTED
213+
AS TCP (LISTENER_PORT=5022, LISTENER_IP = ALL)
214+
FOR DATABASE_MIRRORING (
215+
ROLE=ALL,
216+
AUTHENTICATION = CERTIFICATE TEST_CERT,
217+
ENCRYPTION = REQUIRED ALGORITHM AES
218+
)
220219
```
221220

222221
Connect to Managed Instance and execute following T-SQL to create new SQL Agent job called “NetHelper”.
223222

224223
```sql
225-
-- SQL_SERVER_ADDRESS should be public IP address, or DNS name that can be resolved from the Managed Instance host machine.
226-
DECLARE @SQLServerIpAddress NVARCHAR(MAX) = '<SQL_SERVER_ADDRESS>'
227-
DECLARE @tncCommand NVARCHAR(MAX) = 'tnc ' + @SQLServerIpAddress + ' -port 5022 -InformationLevel Quiet'
228-
DECLARE @jobId BINARY(16)
229-
230-
EXEC msdb.dbo.sp_add_job @job_name=N'NetHelper',
231-
@enabled=1,
232-
@description=N'Test Managed Instance to SQL Server network connectivity on port 5022.',
233-
@category_name=N'[Uncategorized (Local)]',
234-
@owner_login_name=N'cloudSA', @job_id = @jobId OUTPUT
235-
236-
EXEC msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'tnc step',
237-
@step_id=1,
238-
@os_run_priority=0, @subsystem=N'PowerShell',
239-
@command = @tncCommand,
240-
@database_name=N'master',
241-
@flags=40
242-
243-
EXEC msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
244-
245-
EXEC msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
246-
247-
EXEC msdb.dbo.sp_start_job @job_name = N'NetHelper'
224+
-- SQL_SERVER_ADDRESS should be public IP address, or DNS name that can be resolved from the Managed Instance host machine.
225+
DECLARE @SQLServerIpAddress NVARCHAR(MAX) = '<SQL_SERVER_ADDRESS>'
226+
DECLARE @tncCommand NVARCHAR(MAX) = 'tnc ' + @SQLServerIpAddress + ' -port 5022 -InformationLevel Quiet'
227+
DECLARE @jobId BINARY(16)
228+
229+
EXEC msdb.dbo.sp_add_job @job_name=N'NetHelper',
230+
@enabled=1,
231+
@description=N'Test Managed Instance to SQL Server network connectivity on port 5022.',
232+
@category_name=N'[Uncategorized (Local)]',
233+
@owner_login_name=N'cloudSA', @job_id = @jobId OUTPUT
234+
235+
EXEC msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'tnc step',
236+
@step_id=1,
237+
@os_run_priority=0, @subsystem=N'PowerShell',
238+
@command = @tncCommand,
239+
@database_name=N'master',
240+
@flags=40
241+
242+
EXEC msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
243+
244+
EXEC msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
245+
246+
EXEC msdb.dbo.sp_start_job @job_name = N'NetHelper'
248247
```
249248

250249
Execute the agent job by running the following T-SQL command.
251250
```sql
252-
EXEC msdb.dbo.sp_start_job @job_name = N'NetHelper'
251+
EXEC msdb.dbo.sp_start_job @job_name = N'NetHelper'
253252
```
254253

255254
Execute the following query to show the log of the Agent job.
256255

257256
```sql
258-
SELECT
259-
sj.name JobName, sjs.step_id, sjs.step_name, sjsl.log, sjsl.date_modified
260-
FROM
261-
msdb.dbo.sysjobs sj
262-
LEFT OUTER JOIN msdb.dbo.sysjobsteps sjs
263-
ON sj.job_id = sjs.job_id
264-
LEFT OUTER JOIN msdb.dbo.sysjobstepslogs sjsl
265-
ON sjs.step_uid = sjsl.step_uid
266-
WHERE
267-
sj.name = 'NetHelper'
257+
SELECT
258+
sj.name JobName, sjs.step_id, sjs.step_name, sjsl.log, sjsl.date_modified
259+
FROM
260+
msdb.dbo.sysjobs sj
261+
LEFT OUTER JOIN msdb.dbo.sysjobsteps sjs
262+
ON sj.job_id = sjs.job_id
263+
LEFT OUTER JOIN msdb.dbo.sysjobstepslogs sjsl
264+
ON sjs.step_uid = sjsl.step_uid
265+
WHERE
266+
sj.name = 'NetHelper'
268267
```
269268

270269
The result from executing the `tnc` (test network connection) will be False if no connection from Managed Instance to the destination IP could made on the port 5022. If the connection is successful, the log will show True, otherwise False.
271270

272-
:::image type="content" source="./media/managed-instance-link-preparation/ssms-output-tnchelper.png" alt-text="Screenshot showing expected output of NetHelper SQL Agent job.":::
271+
:::image type="content" source="./media/managed-instance-link-preparation/ssms-output-tnchelper.png" alt-text="Screenshot showing expected output of NetHelper S Q L Agent job.":::
273272

274273
Finally, drop the test endpoint and certificate.
275274

276275
```sql
277-
DROP ENDPOINT TEST_ENDPOINT
278-
GO
279-
DROP CERTIFICATE TEST_CERT
280-
GO
276+
DROP ENDPOINT TEST_ENDPOINT
277+
GO
278+
DROP CERTIFICATE TEST_CERT
279+
GO
281280
```
282281

283282
If the log doesn't show True, here is what you can check:
@@ -296,7 +295,7 @@ With this, we've verified that there is bidirectional network connectivity on th
296295
SSMS with Managed Instance link wizard is the easiest and the most recommended way to use Managed Instance link. Download SSMS version 18.11.1 (or newer) from this [link](https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms) and install it on your client machine.
297296
Once the installation is complete, start SSMS and connect to SQL Server that is prepared for Managed Instance link. In the context menu of a user database, you'll find “Azure SQL Managed Instance link” option.
298297

299-
:::image type="content" source="./media/managed-instance-link-preparation/ssms-database-context-menu-managed-instance-link.png" alt-text="Screenshot showing Azure SQL Managed Instance link option in the context menu.":::
298+
:::image type="content" source="./media/managed-instance-link-preparation/ssms-database-context-menu-managed-instance-link.png" alt-text="Screenshot showing Azure S Q L Managed Instance link option in the context menu.":::
300299

301300
## Next steps
302301

articles/azure-sql/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,8 @@
927927
href: managed-instance/managed-instance-link-use-ssms-to-replicate-database.md
928928
- name: Use SSMS to failover database
929929
href: managed-instance/managed-instance-link-use-ssms-to-failover-database.md
930+
- name: Managed Instance link preparation
931+
href: managed-instance/managed-instance-link-preparation.md
930932

931933
- name: Migration guides
932934
items:

0 commit comments

Comments
 (0)