You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: azure-sql/includes/sql-vm-powershell.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,21 @@
1
1
---
2
2
author: MikeRayMSFT
3
3
ms.author: mikeray
4
-
ms.date: 11/25/2018
4
+
ms.reviewer: mathoma
5
+
ms.date: 09/22/2025
5
6
ms.service: azure-vm-sql-server
6
7
ms.topic: include
7
-
ms.custom:
8
8
---
9
9
10
10
## Start your PowerShell session
11
-
12
11
13
-
Run the [**Connect-Az Account**](/powershell/module/Az.Accounts/Connect-AzAccount) cmdlet and you will be presented with a sign-in screen to enter your credentials. Use the same credentials that you use to sign in to the Azure portal.
12
+
Run the [**Connect-AzAccount**](/powershell/module/Az.Accounts/Connect-AzAccount) cmdlet and you're presented with a sign-in screen to enter your credentials. Use the same credentials that you use to sign in to the Azure portal.
14
13
15
14
```powershell
16
15
Connect-AzAccount
17
16
```
18
17
19
-
If you have multiple subscriptions use the [**Set-AzContext**](/powershell/module/az.accounts/set-azcontext) cmdlet to select which subscription your PowerShell session should use. To see what subscription the current PowerShell session is using, run [**Get-AzContext**](/powershell/module/az.accounts/get-azcontext). To see all your subscriptions, run [**Get-AzSubscription**](/powershell/module/az.accounts/get-azsubscription).
18
+
If you have multiple subscriptions, use the [**Set-AzContext**](/powershell/module/az.accounts/set-azcontext) cmdlet to select which subscription your PowerShell session should use. To see what subscription the current PowerShell session is using, run [**Get-AzContext**](/powershell/module/az.accounts/get-azcontext). To see all your subscriptions, run [**Get-AzSubscription**](/powershell/module/az.accounts/get-azsubscription).
The availability group listener is an IP address and network name that the SQL Server availability group listens on. To create the availability group listener:
10
12
11
13
1. <aname="getnet"></a>Get the name of the cluster network resource:
12
14
13
-
a. Use RDP to connect to the Azure virtual machine that hosts the primary replica.
15
+
a. Use [Bastion](/azure/bastion/bastion-connect-vm-rdp-windows) to connect to the Azure virtual machine that hosts the primary replica.
14
16
15
-
b. Open **Failover Cluster Manager**.
17
+
b. Open **Failover Cluster Manager**.
16
18
17
-
c. Select the **Networks** node, and note the cluster network name. Use this name in the `$ClusterNetworkName` variable in the PowerShell script. In the following image, the cluster network name is **Cluster Network 1**:
19
+
c. Select the **Networks** node, and note the cluster network name. Use this name in the `$ClusterNetworkName` variable in the PowerShell script. In the following image, the cluster network name is **Cluster Network 1**:
18
20
19
-
:::image type="content" source="./media/virtual-machines-ag-listener-configure/90-cluster-network-name.png" alt-text="Screenshot that shows a cluster network name in Failover Cluster Manager.":::
21
+
:::image type="content" source="./media/virtual-machines-ag-listener-configure/90-cluster-network-name.png" alt-text="Screenshot that shows a cluster network name in Failover Cluster Manager.":::
20
22
21
23
1. <aname="addcap"></a>Add the client access point. The client access point is the network name that applications use to connect to the databases in an availability group.
22
24
23
-
a. In **Failover Cluster Manager**, expand the cluster name, and then select **Roles**.
25
+
a. In **Failover Cluster Manager**, expand the cluster name, and then select **Roles**.
24
26
25
-
b. On the **Roles** pane, right-click the availability group name, and then select **Add Resource** > **Client Access Point**.
27
+
b. On the **Roles** pane, right-click the availability group name, and then select **Add Resource** > **Client Access Point**.
26
28
27
-
:::image type="content" source="./media/virtual-machines-ag-listener-configure/92-add-client-access-point.png" alt-text="Screenshot of Failover Cluster Manager that shows selecting the Client Access Point command on the shortcut menu for the availability group.":::
29
+
:::image type="content" source="./media/virtual-machines-ag-listener-configure/92-add-client-access-point.png" alt-text="Screenshot of Failover Cluster Manager that shows selecting the Client Access Point command on the shortcut menu for the availability group.":::
28
30
29
-
c. In the **Name** box, create a name for this new listener.
30
-
The name for the new listener is the network name that applications use to connect to databases in the SQL Server availability group.
31
+
c. In the **Name** box, create a name for this new listener.
32
+
The name for the new listener is the network name that applications use to connect to databases in the SQL Server availability group.
31
33
32
-
d. To finish creating the listener, select **Next** twice, and then select **Finish**. Don't bring the listener or resource online at this point.
34
+
d. To finish creating the listener, select **Next** twice, and then select **Finish**. Don't bring the listener or resource online at this point.
33
35
34
36
1. Take the cluster role for the availability group offline. In **Failover Cluster Manager**, under **Roles**, right-click the role, and then select **Stop Role**.
35
37
36
38
1. <aname="congroup"></a>Configure the IP resource for the availability group:
37
39
38
-
a. Select the **Resources** tab, and then expand the client access point that you created. The client access point is offline.
40
+
a. Select the **Resources** tab, and then expand the client access point that you created. The client access point is offline.
39
41
40
42
:::image type="content" source="./media/virtual-machines-ag-listener-configure/94-new-client-access-point.png" alt-text="Screenshot of Failover Cluster Manager that shows an offline status for a client access point.":::
41
43
42
-
b. Right-click the IP resource, and then select **Properties**. Note the name of the IP address, and use it in the `$IPResourceName` variable in the PowerShell script.
44
+
b. Right-click the IP resource, and then select **Properties**. Note the name of the IP address, and use it in the `$IPResourceName` variable in the PowerShell script.
43
45
44
-
c. Under **IP Address**, select **Static IP Address**. Set the IP address as the same address that you used when you set the load balancer address on the Azure portal.
46
+
c. Under **IP Address**, select **Static IP Address**. Set the IP address as the same address that you used when you set the load balancer address on the Azure portal.
45
47
46
48
:::image type="content" source="./media/virtual-machines-ag-listener-configure/96-ip-resource.png" alt-text="Screenshot of Failover Cluster Manager that shows the selection of an IP address.":::
47
49
48
50
1. <aname = "dependencyGroup"></a>Make the SQL Server availability group dependent on the client access point:
49
51
50
-
a. In **Failover Cluster Manager**, select **Roles**, and then select your availability group.
52
+
a. In **Failover Cluster Manager**, select **Roles**, and then select your availability group.
51
53
52
-
b. On the **Resources** tab, under **Other Resources**, right-click the availability group resource, and then select **Properties**.
54
+
b. On the **Resources** tab, under **Other Resources**, right-click the availability group resource, and then select **Properties**.
53
55
54
-
c. On the **Dependencies** tab, add the name of the client access point (the listener).
56
+
c. On the **Dependencies** tab, add the name of the client access point (the listener).
55
57
56
58
:::image type="content" source="./media/virtual-machines-ag-listener-configure/97-properties-dependencies.png" alt-text="Screenshot of Failover Cluster Manager that shows adding a name on the Dependencies tab.":::
57
59
58
-
d. Select **OK**.
60
+
d. Select **OK**.
59
61
60
62
1. <aname="listname"></a>Make the client access point dependent on the IP address:
61
63
62
-
a. In **Failover Cluster Manager**, select **Roles**, and then select your availability group.
64
+
a. In **Failover Cluster Manager**, select **Roles**, and then select your availability group.
63
65
64
-
b. On the **Resources** tab, right-click the client access point under **Server Name**, and then select **Properties**.
66
+
b. On the **Resources** tab, right-click the client access point under **Server Name**, and then select **Properties**.
65
67
66
68
:::image type="content" source="./media/virtual-machines-ag-listener-configure/98-dependencies.png" alt-text="Screenshot of Failover Cluster Manager that shows the Properties menu option for the listener's name.":::
67
69
68
-
c. Select the **Dependencies** tab. Verify that the IP address is a dependency. If it isn't, set a dependency on the IP address. If multiple resources are listed, verify that the IP addresses have **OR**, not **AND**, dependencies. Then select **OK**.
70
+
c. Select the **Dependencies** tab. Verify that the IP address is a dependency. If it isn't, set a dependency on the IP address. If multiple resources are listed, verify that the IP addresses have `OR`, not `AND`, dependencies. Then select **OK**.
69
71
70
72
:::image type="content" source="./media/virtual-machines-ag-listener-configure/98-properties-dependencies.png" alt-text="Screenshot of the Dependencies tab that shows an IP resource for an availability group.":::
71
73
72
-
>[!TIP]
73
-
>You can validate that the dependencies are correctly configured. In **Failover Cluster Manager**, go to **Roles**, right-click the availability group, select **More Actions**, and then select **Show Dependency Report**. When the dependencies are correctly configured, the availability group is dependent on the network name, and the network name is dependent on the IP address.
74
+
> [!TIP]
75
+
> You can validate that the dependencies are correctly configured. In **Failover Cluster Manager**, go to **Roles**, right-click the availability group, select **More Actions**, and then select **Show Dependency Report**. When the dependencies are correctly configured, the availability group is dependent on the network name, and the network name is dependent on the IP address.
74
76
75
77
76
78
1. <aname="setparam"></a>Set the cluster parameters in PowerShell:
@@ -90,15 +92,15 @@ The availability group listener is an IP address and network name that the SQL S
90
92
$IPResourceName = "<IPResourceName>" # The IP address resource name.
91
93
$ListenerILBIP = "<n.n.n.n>" # The IP address of the internal load balancer. This is the static IP address for the load balancer that you configured in the Azure portal.
b. Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
101
+
b. Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
100
102
101
-
> [!NOTE]
103
+
> [!NOTE]
102
104
> If your SQL Server instances are in separate regions, you need to run the PowerShell script twice. The first time, use the `$ListenerILBIP` and `$ListenerProbePort` values from the first region. The second time, use the `$ListenerILBIP` and `$ListenerProbePort` values from the second region. The cluster network name and the cluster IP resource name are also different for each region.
103
105
104
106
1. Bring the cluster role for the availability group online. In **Failover Cluster Manager**, under **Roles**, right-click the role, and then select **Start Role**.
@@ -109,7 +111,7 @@ If necessary, repeat the preceding steps to set the cluster parameters for the I
109
111
110
112
1. Right-click **IP Address**, and then select **Properties**.
111
113
112
-
1. Copy the name of the IP address from **Name**. It might be **Cluster IP Address**.
114
+
1. Copy the name of the IP address from **Name**. It might be **Cluster IP Address**.
113
115
114
116
1. <aname="setwsfcparam"></a>Set the cluster parameters in PowerShell:
115
117
@@ -124,29 +126,29 @@ If necessary, repeat the preceding steps to set the cluster parameters for the I
124
126
$IPResourceName = "<ClusterIPResourceName>" # The IP address resource name.
125
127
$ClusterCoreIP = "<n.n.n.n>" # The IP address of the cluster IP resource. This is the static IP address for the load balancer that you configured in the Azure portal.
126
128
[int]$ClusterProbePort = <nnnnn> # The probe port from WSFCEndPointprobe in the Azure portal. This port must be different from the probe port for the availability group listener.
b. Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
135
+
b. Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
134
136
135
-
If any SQL resource is configured to use a port between 49152 and 65536 (the [default dynamic port range for TCP/IP](/windows/client-management/troubleshoot-tcpip-port-exhaust#default-dynamic-port-range-for-tcpip)), add an exclusion for each port. Such resources might include:
137
+
If any SQL resource is configured to use a port between 49,152 and 65,536 (the [default dynamic port range for TCP/IP](/windows/client-management/troubleshoot-tcpip-port-exhaust#default-dynamic-port-range-for-tcpip)), add an exclusion for each port. Such resources might include:
136
138
137
139
- SQL Server database engine
138
140
- Always On availability group listener
139
141
- Health probe for the failover cluster instance
140
142
- Database mirroring endpoint
141
-
- Cluster core IP resource
143
+
- Cluster core IP resource
142
144
143
145
Adding an exclusion will prevent other system processes from being dynamically assigned to the same port. For this scenario, configure the following exclusions on all cluster nodes:
144
146
145
147
-`netsh int ipv4 add excludedportrange tcp startport=58888 numberofports=1 store=persistent`
146
148
-`netsh int ipv4 add excludedportrange tcp startport=59999 numberofports=1 store=persistent`
147
149
148
-
It's important to configure the port exclusion when the port is not in use. Otherwise, the command will fail with a message like "The process cannot access the file because it is being used by another process."
149
-
To confirm that the exclusions are configured correctly, use the following command: `netsh int ipv4 show excludedportrange tcp`.
150
+
It's important to configure the port exclusion when the port isn't in use. Otherwise, the command will fail with a message like `The process cannot access the file because it is being used by another process`.
151
+
To confirm that the exclusions are configured correctly, use the following command: `netsh int ipv4 show excludedportrange tcp`.
150
152
151
-
>[!WARNING]
152
-
>The port for the availability group listener's health probe has to be different from the port for the cluster core IP address's health probe. In these examples, the listener port is 59999 and the cluster core IP address's health probe port is 58888. Both ports require an "allow inbound" firewall rule.
153
+
>[!WARNING]
154
+
>The port for the availability group listener's health probe has to be different from the port for the cluster core IP address's health probe. In these examples, the listener port is 59999 and the cluster core IP address's health probe port is 58888. Both ports require an "allow inbound" firewall rule.
0 commit comments