Skip to content

Commit dfcdc5c

Browse files
authored
Add secondary type support in sql failover group (#25085)
* added secondary type support in failover group * fix typo in switch failover group command
1 parent 3410b61 commit dfcdc5c

File tree

41 files changed

+38274
-107883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+38274
-107883
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
9090
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
9191
}
9292

93-
string apiVersion = "2023-02-01-preview";
93+
string apiVersion = "2023-05-01-preview";
9494
// Tracing
9595
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
9696
string _invocationId = null;
@@ -309,7 +309,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
309309
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
310310
}
311311

312-
string apiVersion = "2023-02-01-preview";
312+
string apiVersion = "2023-05-01-preview";
313313
// Tracing
314314
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
315315
string _invocationId = null;
@@ -705,7 +705,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
705705
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
706706
}
707707

708-
string apiVersion = "2023-02-01-preview";
708+
string apiVersion = "2023-05-01-preview";
709709
// Tracing
710710
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
711711
string _invocationId = null;
@@ -948,7 +948,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
948948
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
949949
}
950950

951-
string apiVersion = "2023-02-01-preview";
951+
string apiVersion = "2023-05-01-preview";
952952
// Tracing
953953
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
954954
string _invocationId = null;
@@ -1158,7 +1158,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
11581158
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
11591159
}
11601160

1161-
string apiVersion = "2023-02-01-preview";
1161+
string apiVersion = "2023-05-01-preview";
11621162
// Tracing
11631163
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
11641164
string _invocationId = null;
@@ -1386,7 +1386,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
13861386
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
13871387
}
13881388

1389-
string apiVersion = "2023-02-01-preview";
1389+
string apiVersion = "2023-05-01-preview";
13901390
// Tracing
13911391
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
13921392
string _invocationId = null;
@@ -1608,7 +1608,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
16081608
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
16091609
}
16101610

1611-
string apiVersion = "2023-02-01-preview";
1611+
string apiVersion = "2023-05-01-preview";
16121612
// Tracing
16131613
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
16141614
string _invocationId = null;
@@ -1830,7 +1830,7 @@ internal FailoverGroupsOperations (SqlManagementClient client)
18301830
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
18311831
}
18321832

1833-
string apiVersion = "2023-02-01-preview";
1833+
string apiVersion = "2023-05-01-preview";
18341834
// Tracing
18351835
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
18361836
string _invocationId = null;

src/Sql/Sql.Management.Sdk/Generated/Models/FailoverGroup.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public FailoverGroup()
5757

5858
/// <param name="databases">List of databases in the failover group.
5959
/// </param>
60-
public FailoverGroup(string id = default(string), string name = default(string), string type = default(string), string location = default(string), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), FailoverGroupReadWriteEndpoint readWriteEndpoint = default(FailoverGroupReadWriteEndpoint), FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), string replicationRole = default(string), string replicationState = default(string), System.Collections.Generic.IList<PartnerInfo> partnerServers = default(System.Collections.Generic.IList<PartnerInfo>), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>))
60+
61+
/// <param name="secondaryType">Databases secondary type on partner server.
62+
/// Possible values include: &#39;Geo&#39;, &#39;Standby&#39;</param>
63+
public FailoverGroup(string id = default(string), string name = default(string), string type = default(string), string location = default(string), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), FailoverGroupReadWriteEndpoint readWriteEndpoint = default(FailoverGroupReadWriteEndpoint), FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), string replicationRole = default(string), string replicationState = default(string), System.Collections.Generic.IList<PartnerInfo> partnerServers = default(System.Collections.Generic.IList<PartnerInfo>), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>), string secondaryType = default(string))
6164

6265
: base(id, name, type)
6366
{
@@ -69,6 +72,7 @@ public FailoverGroup()
6972
this.ReplicationState = replicationState;
7073
this.PartnerServers = partnerServers;
7174
this.Databases = databases;
75+
this.SecondaryType = secondaryType;
7276
CustomInit();
7377
}
7478

@@ -125,6 +129,12 @@ public FailoverGroup()
125129
/// </summary>
126130
[Newtonsoft.Json.JsonProperty(PropertyName = "properties.databases")]
127131
public System.Collections.Generic.IList<string> Databases {get; set; }
132+
133+
/// <summary>
134+
/// Gets or sets databases secondary type on partner server. Possible values include: &#39;Geo&#39;, &#39;Standby&#39;
135+
/// </summary>
136+
[Newtonsoft.Json.JsonProperty(PropertyName = "properties.secondaryType")]
137+
public string SecondaryType {get; set; }
128138
/// <summary>
129139
/// Validate the object.
130140
/// </summary>
@@ -153,6 +163,7 @@ public virtual void Validate()
153163
}
154164
}
155165

166+
156167
}
157168
}
158169
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
// Code generated by Microsoft (R) AutoRest Code Generator.
4+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
5+
6+
namespace Microsoft.Azure.Management.Sql.Models
7+
{
8+
9+
/// <summary>
10+
/// Defines values for FailoverGroupDatabasesSecondaryType.
11+
/// </summary>
12+
13+
14+
public static class FailoverGroupDatabasesSecondaryType
15+
{
16+
public const string Geo = "Geo";
17+
public const string Standby = "Standby";
18+
}
19+
}

src/Sql/Sql.Management.Sdk/Generated/Models/FailoverGroupProperties.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ public FailoverGroupProperties()
4141

4242
/// <param name="databases">List of databases in the failover group.
4343
/// </param>
44-
public FailoverGroupProperties(FailoverGroupReadWriteEndpoint readWriteEndpoint, System.Collections.Generic.IList<PartnerInfo> partnerServers, FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), string replicationRole = default(string), string replicationState = default(string), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>))
44+
45+
/// <param name="secondaryType">Databases secondary type on partner server.
46+
/// Possible values include: &#39;Geo&#39;, &#39;Standby&#39;</param>
47+
public FailoverGroupProperties(FailoverGroupReadWriteEndpoint readWriteEndpoint, System.Collections.Generic.IList<PartnerInfo> partnerServers, FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), string replicationRole = default(string), string replicationState = default(string), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>), string secondaryType = default(string))
4548

4649
{
4750
this.ReadWriteEndpoint = readWriteEndpoint;
@@ -50,6 +53,7 @@ public FailoverGroupProperties()
5053
this.ReplicationState = replicationState;
5154
this.PartnerServers = partnerServers;
5255
this.Databases = databases;
56+
this.SecondaryType = secondaryType;
5357
CustomInit();
5458
}
5559

@@ -94,6 +98,12 @@ public FailoverGroupProperties()
9498
/// </summary>
9599
[Newtonsoft.Json.JsonProperty(PropertyName = "databases")]
96100
public System.Collections.Generic.IList<string> Databases {get; set; }
101+
102+
/// <summary>
103+
/// Gets or sets databases secondary type on partner server. Possible values include: &#39;Geo&#39;, &#39;Standby&#39;
104+
/// </summary>
105+
[Newtonsoft.Json.JsonProperty(PropertyName = "secondaryType")]
106+
public string SecondaryType {get; set; }
97107
/// <summary>
98108
/// Validate the object.
99109
/// </summary>
@@ -128,6 +138,7 @@ public virtual void Validate()
128138
}
129139
}
130140

141+
131142
}
132143
}
133144
}

src/Sql/Sql.Management.Sdk/Generated/Models/FailoverGroupUpdate.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ public FailoverGroupUpdate()
3939

4040
/// <param name="partnerServers">List of partner server information for the failover group.
4141
/// </param>
42-
public FailoverGroupUpdate(System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), FailoverGroupReadWriteEndpoint readWriteEndpoint = default(FailoverGroupReadWriteEndpoint), FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>), System.Collections.Generic.IList<PartnerInfo> partnerServers = default(System.Collections.Generic.IList<PartnerInfo>))
42+
43+
/// <param name="secondaryType">Databases secondary type on partner server.
44+
/// Possible values include: &#39;Geo&#39;, &#39;Standby&#39;</param>
45+
public FailoverGroupUpdate(System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), FailoverGroupReadWriteEndpoint readWriteEndpoint = default(FailoverGroupReadWriteEndpoint), FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>), System.Collections.Generic.IList<PartnerInfo> partnerServers = default(System.Collections.Generic.IList<PartnerInfo>), string secondaryType = default(string))
4346

4447
{
4548
this.Tags = tags;
4649
this.ReadWriteEndpoint = readWriteEndpoint;
4750
this.ReadOnlyEndpoint = readOnlyEndpoint;
4851
this.Databases = databases;
4952
this.PartnerServers = partnerServers;
53+
this.SecondaryType = secondaryType;
5054
CustomInit();
5155
}
5256

@@ -85,6 +89,12 @@ public FailoverGroupUpdate()
8589
/// </summary>
8690
[Newtonsoft.Json.JsonProperty(PropertyName = "properties.partnerServers")]
8791
public System.Collections.Generic.IList<PartnerInfo> PartnerServers {get; set; }
92+
93+
/// <summary>
94+
/// Gets or sets databases secondary type on partner server. Possible values include: &#39;Geo&#39;, &#39;Standby&#39;
95+
/// </summary>
96+
[Newtonsoft.Json.JsonProperty(PropertyName = "properties.secondaryType")]
97+
public string SecondaryType {get; set; }
8898
/// <summary>
8999
/// Validate the object.
90100
/// </summary>
@@ -110,6 +120,7 @@ public virtual void Validate()
110120
}
111121
}
112122
}
123+
113124
}
114125
}
115126
}

src/Sql/Sql.Management.Sdk/Generated/Models/FailoverGroupUpdateProperties.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ public FailoverGroupUpdateProperties()
3535

3636
/// <param name="partnerServers">List of partner server information for the failover group.
3737
/// </param>
38-
public FailoverGroupUpdateProperties(FailoverGroupReadWriteEndpoint readWriteEndpoint = default(FailoverGroupReadWriteEndpoint), FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>), System.Collections.Generic.IList<PartnerInfo> partnerServers = default(System.Collections.Generic.IList<PartnerInfo>))
38+
39+
/// <param name="secondaryType">Databases secondary type on partner server.
40+
/// Possible values include: &#39;Geo&#39;, &#39;Standby&#39;</param>
41+
public FailoverGroupUpdateProperties(FailoverGroupReadWriteEndpoint readWriteEndpoint = default(FailoverGroupReadWriteEndpoint), FailoverGroupReadOnlyEndpoint readOnlyEndpoint = default(FailoverGroupReadOnlyEndpoint), System.Collections.Generic.IList<string> databases = default(System.Collections.Generic.IList<string>), System.Collections.Generic.IList<PartnerInfo> partnerServers = default(System.Collections.Generic.IList<PartnerInfo>), string secondaryType = default(string))
3942

4043
{
4144
this.ReadWriteEndpoint = readWriteEndpoint;
4245
this.ReadOnlyEndpoint = readOnlyEndpoint;
4346
this.Databases = databases;
4447
this.PartnerServers = partnerServers;
48+
this.SecondaryType = secondaryType;
4549
CustomInit();
4650
}
4751

@@ -74,6 +78,12 @@ public FailoverGroupUpdateProperties()
7478
/// </summary>
7579
[Newtonsoft.Json.JsonProperty(PropertyName = "partnerServers")]
7680
public System.Collections.Generic.IList<PartnerInfo> PartnerServers {get; set; }
81+
82+
/// <summary>
83+
/// Gets or sets databases secondary type on partner server. Possible values include: &#39;Geo&#39;, &#39;Standby&#39;
84+
/// </summary>
85+
[Newtonsoft.Json.JsonProperty(PropertyName = "secondaryType")]
86+
public string SecondaryType {get; set; }
7787
/// <summary>
7888
/// Validate the object.
7989
/// </summary>
@@ -98,6 +108,7 @@ public virtual void Validate()
98108
}
99109
}
100110
}
111+
101112
}
102113
}
103114
}

src/Sql/Sql.Management.Sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ input-file:
113113
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/ManagedLedgerDigestUploads.json
114114
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/ManagedDatabases.json
115115
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/ElasticPools.json
116-
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/FailoverGroups.json
116+
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/FailoverGroups.json
117117
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/ManagedDatabaseMoveOperations.json
118118
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/ManagedInstances.json
119119
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/StartStopManagedInstanceSchedules.json

src/Sql/Sql.Test/ScenarioTests/FailoverGroupTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,12 @@ public void TestFailoverGroupMultipleSecondaries()
179179
{
180180
TestRunner.RunTestScript("Test-FailoverGroupMultipleSecondaries");
181181
}
182+
183+
[Fact]
184+
[Trait(Category.AcceptanceType, Category.CheckIn)]
185+
public void TestAddRemoveDatabasesToFromFailoverGroupWithStandby()
186+
{
187+
TestRunner.RunTestScript("Test-AddRemoveDatabasesToFromFailoverGroupWithStandby");
188+
}
182189
}
183190
}

src/Sql/Sql.Test/ScenarioTests/FailoverGroupTests.ps1

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15-
function Handle-FailoverGroupTest($scriptBlock, $primaryLocation = "North Europe", $secondaryLocation = "West Europe", $serverVersion = "12.0", $rg = $null, $server1 = $null, $server2 = $null, $cleanup = $false)
15+
function Handle-FailoverGroupTest($scriptBlock, $primaryLocation = "North Europe", $secondaryLocation = "East US", $serverVersion = "12.0", $rg = $null, $server1 = $null, $server2 = $null, $cleanup = $false)
1616
{
1717
try
1818
{
@@ -443,4 +443,31 @@ function Test-FailoverGroupMultipleSecondaries()
443443
$fg = New-AzSqlDatabaseFailoverGroup -ResourceGroupName $primaryServer.ResourceGroupName -ServerName $primaryServer.ServerName -PartnerServerName $partnerServer.ServerName -FailoverGroupName $fgName -FailoverPolicy Automatic -GracePeriodWithDataLossHours 1 -AllowReadOnlyFailoverToPrimary Enabled -PartnerServerList $partnerServers -ReadOnlyEndpointTargetServer $partnerServer.ResourceId
444444
Validate-FailoverGroup $primaryServer $server $fgName Primary Automatic 1 Enabled @() $fg -isMultiServer $true -PartnerServerList $partnerServers
445445
}
446+
}
447+
448+
function Test-AddRemoveDatabasesToFromFailoverGroupWithStandby()
449+
{
450+
Handle-FailoverGroupTestWithFailoverGroup {
451+
Param($fg)
452+
453+
$db1 = New-AzSqlDatabase $fg.ResourceGroupName $fg.ServerName -DatabaseName (Get-DatabaseName)
454+
455+
$newFg = $fg | Add-AzSqlDatabaseToFailoverGroup -Database $db1 -SecondaryType "Standby"
456+
Assert-FailoverGroupsEqual $fg $newFg -databases @($db1) -message "after adding db1"
457+
Validate-FailoverGroupWithGet $newFg -message "get after adding db1"
458+
459+
$newFg = $fg | Remove-AzSqlDatabaseFromFailoverGroup -Database $db1
460+
Assert-FailoverGroupsEqual $fg $newFg -databases @() -message "after removing db1"
461+
Validate-FailoverGroupWithGet $newFg -message "get after removing db1"
462+
463+
$db2 = New-AzSqlDatabase $fg.ResourceGroupName $fg.ServerName -DatabaseName (Get-DatabaseName)
464+
465+
$newFg = Add-AzSqlDatabaseToFailoverGroup -ResourceGroupName $fg.ResourceGroupName -ServerName $fg.ServerName -FailoverGroupName $fg.FailoverGroupName -Database @($db1, $db2) -SecondaryType "Standby"
466+
Assert-FailoverGroupsEqual $fg $newFg -databases @($db1, $db2) -message "after adding both dbs"
467+
Validate-FailoverGroupWithGet $newFg -message "get after adding both dbs"
468+
469+
$newFg = Remove-AzSqlDatabaseFromFailoverGroup -ResourceGroupName $fg.ResourceGroupName -ServerName $fg.ServerName -FailoverGroupName $fg.FailoverGroupName -Database @($db1, $db2)
470+
Assert-FailoverGroupsEqual $fg $newFg -databases @() -message "after removing both dbs"
471+
Validate-FailoverGroupWithGet $newFg -message "get after removing both dbs"
472+
}
446473
}

0 commit comments

Comments
 (0)