Skip to content

Commit 98eff51

Browse files
subhrobsubhrob
andauthored
[SQL] Add TryPlannedBeforeForcedFailover parameter to Switch-AzSqlDatabaseFailoverGroup (#21897)
* Add Failover option TryPlannedBeforeForcedFailover * Update help file * Add -TryPlannedBeforeForcedFailover Test * Update ChangeLog.md * Modify description * Add test * Remove parameter set * Modify help file * Upload test records * Remove pattern check * update README * update README * Addressed review comments --------- Co-authored-by: subhrob <[email protected]>
1 parent 3a71fc8 commit 98eff51

File tree

36 files changed

+97094
-631455
lines changed

36 files changed

+97094
-631455
lines changed

src/Sql/Sql.Sdk/Generated/FailoverGroupsOperations.cs

Lines changed: 354 additions & 109 deletions
Large diffs are not rendered by default.

src/Sql/Sql.Sdk/Generated/FailoverGroupsOperationsExtensions.cs

Lines changed: 120 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,48 @@ namespace Microsoft.Azure.Management.Sql
2121
/// </summary>
2222
public static partial class FailoverGroupsOperationsExtensions
2323
{
24+
/// <summary>
25+
/// Lists the failover groups in a server.
26+
/// </summary>
27+
/// <param name='operations'>
28+
/// The operations group for this extension method.
29+
/// </param>
30+
/// <param name='resourceGroupName'>
31+
/// The name of the resource group that contains the resource. You can obtain
32+
/// this value from the Azure Resource Manager API or the portal.
33+
/// </param>
34+
/// <param name='serverName'>
35+
/// The name of the server containing the failover group.
36+
/// </param>
37+
public static IPage<FailoverGroup> ListByServer(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName)
38+
{
39+
return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult();
40+
}
41+
42+
/// <summary>
43+
/// Lists the failover groups in a server.
44+
/// </summary>
45+
/// <param name='operations'>
46+
/// The operations group for this extension method.
47+
/// </param>
48+
/// <param name='resourceGroupName'>
49+
/// The name of the resource group that contains the resource. You can obtain
50+
/// this value from the Azure Resource Manager API or the portal.
51+
/// </param>
52+
/// <param name='serverName'>
53+
/// The name of the server containing the failover group.
54+
/// </param>
55+
/// <param name='cancellationToken'>
56+
/// The cancellation token.
57+
/// </param>
58+
public static async Task<IPage<FailoverGroup>> ListByServerAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken))
59+
{
60+
using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false))
61+
{
62+
return _result.Body;
63+
}
64+
}
65+
2466
/// <summary>
2567
/// Gets a failover group.
2668
/// </summary>
@@ -223,7 +265,7 @@ public static FailoverGroup Update(this IFailoverGroupsOperations operations, st
223265
}
224266

225267
/// <summary>
226-
/// Lists the failover groups in a server.
268+
/// Fails over from the current primary server to this server.
227269
/// </summary>
228270
/// <param name='operations'>
229271
/// The operations group for this extension method.
@@ -235,13 +277,16 @@ public static FailoverGroup Update(this IFailoverGroupsOperations operations, st
235277
/// <param name='serverName'>
236278
/// The name of the server containing the failover group.
237279
/// </param>
238-
public static IPage<FailoverGroup> ListByServer(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName)
280+
/// <param name='failoverGroupName'>
281+
/// The name of the failover group.
282+
/// </param>
283+
public static FailoverGroup Failover(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName)
239284
{
240-
return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult();
285+
return operations.FailoverAsync(resourceGroupName, serverName, failoverGroupName).GetAwaiter().GetResult();
241286
}
242287

243288
/// <summary>
244-
/// Lists the failover groups in a server.
289+
/// Fails over from the current primary server to this server.
245290
/// </summary>
246291
/// <param name='operations'>
247292
/// The operations group for this extension method.
@@ -253,19 +298,23 @@ public static IPage<FailoverGroup> ListByServer(this IFailoverGroupsOperations o
253298
/// <param name='serverName'>
254299
/// The name of the server containing the failover group.
255300
/// </param>
301+
/// <param name='failoverGroupName'>
302+
/// The name of the failover group.
303+
/// </param>
256304
/// <param name='cancellationToken'>
257305
/// The cancellation token.
258306
/// </param>
259-
public static async Task<IPage<FailoverGroup>> ListByServerAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken))
307+
public static async Task<FailoverGroup> FailoverAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName, CancellationToken cancellationToken = default(CancellationToken))
260308
{
261-
using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false))
309+
using (var _result = await operations.FailoverWithHttpMessagesAsync(resourceGroupName, serverName, failoverGroupName, null, cancellationToken).ConfigureAwait(false))
262310
{
263311
return _result.Body;
264312
}
265313
}
266314

267315
/// <summary>
268-
/// Fails over from the current primary server to this server.
316+
/// Fails over from the current primary server to this server. This operation
317+
/// might result in data loss.
269318
/// </summary>
270319
/// <param name='operations'>
271320
/// The operations group for this extension method.
@@ -280,13 +329,14 @@ public static IPage<FailoverGroup> ListByServer(this IFailoverGroupsOperations o
280329
/// <param name='failoverGroupName'>
281330
/// The name of the failover group.
282331
/// </param>
283-
public static FailoverGroup Failover(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName)
332+
public static FailoverGroup ForceFailoverAllowDataLoss(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName)
284333
{
285-
return operations.FailoverAsync(resourceGroupName, serverName, failoverGroupName).GetAwaiter().GetResult();
334+
return operations.ForceFailoverAllowDataLossAsync(resourceGroupName, serverName, failoverGroupName).GetAwaiter().GetResult();
286335
}
287336

288337
/// <summary>
289-
/// Fails over from the current primary server to this server.
338+
/// Fails over from the current primary server to this server. This operation
339+
/// might result in data loss.
290340
/// </summary>
291341
/// <param name='operations'>
292342
/// The operations group for this extension method.
@@ -304,17 +354,17 @@ public static FailoverGroup Failover(this IFailoverGroupsOperations operations,
304354
/// <param name='cancellationToken'>
305355
/// The cancellation token.
306356
/// </param>
307-
public static async Task<FailoverGroup> FailoverAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName, CancellationToken cancellationToken = default(CancellationToken))
357+
public static async Task<FailoverGroup> ForceFailoverAllowDataLossAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName, CancellationToken cancellationToken = default(CancellationToken))
308358
{
309-
using (var _result = await operations.FailoverWithHttpMessagesAsync(resourceGroupName, serverName, failoverGroupName, null, cancellationToken).ConfigureAwait(false))
359+
using (var _result = await operations.ForceFailoverAllowDataLossWithHttpMessagesAsync(resourceGroupName, serverName, failoverGroupName, null, cancellationToken).ConfigureAwait(false))
310360
{
311361
return _result.Body;
312362
}
313363
}
314364

315365
/// <summary>
316366
/// Fails over from the current primary server to this server. This operation
317-
/// might result in data loss.
367+
/// tries planned before forced failover but might still result in data loss.
318368
/// </summary>
319369
/// <param name='operations'>
320370
/// The operations group for this extension method.
@@ -324,19 +374,19 @@ public static FailoverGroup Failover(this IFailoverGroupsOperations operations,
324374
/// this value from the Azure Resource Manager API or the portal.
325375
/// </param>
326376
/// <param name='serverName'>
327-
/// The name of the server containing the failover group.
377+
/// The name of the server.
328378
/// </param>
329379
/// <param name='failoverGroupName'>
330380
/// The name of the failover group.
331381
/// </param>
332-
public static FailoverGroup ForceFailoverAllowDataLoss(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName)
382+
public static FailoverGroup TryPlannedBeforeForcedFailover(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName)
333383
{
334-
return operations.ForceFailoverAllowDataLossAsync(resourceGroupName, serverName, failoverGroupName).GetAwaiter().GetResult();
384+
return operations.TryPlannedBeforeForcedFailoverAsync(resourceGroupName, serverName, failoverGroupName).GetAwaiter().GetResult();
335385
}
336386

337387
/// <summary>
338388
/// Fails over from the current primary server to this server. This operation
339-
/// might result in data loss.
389+
/// tries planned before forced failover but might still result in data loss.
340390
/// </summary>
341391
/// <param name='operations'>
342392
/// The operations group for this extension method.
@@ -346,17 +396,17 @@ public static FailoverGroup ForceFailoverAllowDataLoss(this IFailoverGroupsOpera
346396
/// this value from the Azure Resource Manager API or the portal.
347397
/// </param>
348398
/// <param name='serverName'>
349-
/// The name of the server containing the failover group.
399+
/// The name of the server.
350400
/// </param>
351401
/// <param name='failoverGroupName'>
352402
/// The name of the failover group.
353403
/// </param>
354404
/// <param name='cancellationToken'>
355405
/// The cancellation token.
356406
/// </param>
357-
public static async Task<FailoverGroup> ForceFailoverAllowDataLossAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName, CancellationToken cancellationToken = default(CancellationToken))
407+
public static async Task<FailoverGroup> TryPlannedBeforeForcedFailoverAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName, CancellationToken cancellationToken = default(CancellationToken))
358408
{
359-
using (var _result = await operations.ForceFailoverAllowDataLossWithHttpMessagesAsync(resourceGroupName, serverName, failoverGroupName, null, cancellationToken).ConfigureAwait(false))
409+
using (var _result = await operations.TryPlannedBeforeForcedFailoverWithHttpMessagesAsync(resourceGroupName, serverName, failoverGroupName, null, cancellationToken).ConfigureAwait(false))
360410
{
361411
return _result.Body;
362412
}
@@ -613,6 +663,56 @@ public static FailoverGroup BeginForceFailoverAllowDataLoss(this IFailoverGroups
613663
}
614664
}
615665

666+
/// <summary>
667+
/// Fails over from the current primary server to this server. This operation
668+
/// tries planned before forced failover but might still result in data loss.
669+
/// </summary>
670+
/// <param name='operations'>
671+
/// The operations group for this extension method.
672+
/// </param>
673+
/// <param name='resourceGroupName'>
674+
/// The name of the resource group that contains the resource. You can obtain
675+
/// this value from the Azure Resource Manager API or the portal.
676+
/// </param>
677+
/// <param name='serverName'>
678+
/// The name of the server.
679+
/// </param>
680+
/// <param name='failoverGroupName'>
681+
/// The name of the failover group.
682+
/// </param>
683+
public static FailoverGroup BeginTryPlannedBeforeForcedFailover(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName)
684+
{
685+
return operations.BeginTryPlannedBeforeForcedFailoverAsync(resourceGroupName, serverName, failoverGroupName).GetAwaiter().GetResult();
686+
}
687+
688+
/// <summary>
689+
/// Fails over from the current primary server to this server. This operation
690+
/// tries planned before forced failover but might still result in data loss.
691+
/// </summary>
692+
/// <param name='operations'>
693+
/// The operations group for this extension method.
694+
/// </param>
695+
/// <param name='resourceGroupName'>
696+
/// The name of the resource group that contains the resource. You can obtain
697+
/// this value from the Azure Resource Manager API or the portal.
698+
/// </param>
699+
/// <param name='serverName'>
700+
/// The name of the server.
701+
/// </param>
702+
/// <param name='failoverGroupName'>
703+
/// The name of the failover group.
704+
/// </param>
705+
/// <param name='cancellationToken'>
706+
/// The cancellation token.
707+
/// </param>
708+
public static async Task<FailoverGroup> BeginTryPlannedBeforeForcedFailoverAsync(this IFailoverGroupsOperations operations, string resourceGroupName, string serverName, string failoverGroupName, CancellationToken cancellationToken = default(CancellationToken))
709+
{
710+
using (var _result = await operations.BeginTryPlannedBeforeForcedFailoverWithHttpMessagesAsync(resourceGroupName, serverName, failoverGroupName, null, cancellationToken).ConfigureAwait(false))
711+
{
712+
return _result.Body;
713+
}
714+
}
715+
616716
/// <summary>
617717
/// Lists the failover groups in a server.
618718
/// </summary>

0 commit comments

Comments
 (0)