Skip to content

Commit bddb032

Browse files
committed
Review Changes for Replication Cmdlets
-Branding -partner RG check -Error message change
1 parent 89776df commit bddb032

13 files changed

+118
-121
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseReplicationTests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ function Test-CreateDatabaseCopyV2
3737
function Test-CreateCopyInternal ($serverVersion, $location = "North Europe")
3838
{
3939
# Setup
40-
$rg = Create-ResourceGroupForTest
40+
$rg = Create-ResourceGroupForTest $location
4141
$server = Create-ServerForTest $rg $serverVersion $location
4242
$database = Create-DatabaseForTest $rg $server
4343

44-
$copyRg = Create-ResourceGroupForTest
44+
$copyRg = Create-ResourceGroupForTest $location
4545
$copyServer = Create-ServerForTest $copyRg $serverVersion $location
4646
$copyDatabaseName = Get-DatabaseName
4747

@@ -99,11 +99,11 @@ function Test-CreateSecondaryDatabaseV2
9999
function Test-CreateSecondaryDatabaseInternal ($serverVersion, $location = "North Europe")
100100
{
101101
# Setup
102-
$rg = Create-ResourceGroupForTest
102+
$rg = Create-ResourceGroupForTest $location
103103
$server = Create-ServerForTest $rg $serverVersion $location
104104
$database = Create-DatabaseForTest $rg $server
105105

106-
$partRg = Create-ResourceGroupForTest
106+
$partRg = Create-ResourceGroupForTest $location
107107
$partServer = Create-ServerForTest $partRg $serverVersion $location
108108

109109
try
@@ -196,11 +196,11 @@ function Test-GetReplicationLinkV2
196196
function Test-GetReplicationLinkInternal ($serverVersion, $location = "North Europe")
197197
{
198198
# Setup
199-
$rg = Create-ResourceGroupForTest
199+
$rg = Create-ResourceGroupForTest $location
200200
$server = Create-ServerForTest $rg $serverVersion $location
201201
$database = Create-DatabaseForTest $rg $server
202202

203-
$partRg = Create-ResourceGroupForTest
203+
$partRg = Create-ResourceGroupForTest $location
204204
$partServer = Create-ServerForTest $partRg $serverVersion $location
205205

206206
try
@@ -257,11 +257,11 @@ function Test-RemoveSecondaryDatabaseV2
257257
function Test-RemoveSecondaryDatabaseInternal ($serverVersion, $location = "North Europe")
258258
{
259259
# Setup
260-
$rg = Create-ResourceGroupForTest
260+
$rg = Create-ResourceGroupForTest $location
261261
$server = Create-ServerForTest $rg $serverVersion $location
262262
$database = Create-DatabaseForTest $rg $server
263263

264-
$partRg = Create-ResourceGroupForTest
264+
$partRg = Create-ResourceGroupForTest $location
265265
$partServer = Create-ServerForTest $partRg $serverVersion $location
266266

267267
try

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/AzureSqlDatabaseCopyCmdletBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
16-
using System.Management.Automation;
1715
using Microsoft.Azure.Commands.Sql.Common;
1816
using Microsoft.Azure.Commands.Sql.Replication.Model;
1917
using Microsoft.Azure.Commands.Sql.ReplicationLink.Services;
18+
using System.Collections.Generic;
19+
using System.Management.Automation;
2020

2121
namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
2222
{
2323
public abstract class AzureSqlDatabaseCopyCmdletBase : AzureSqlCmdletBase<IEnumerable<AzureSqlDatabaseCopyModel>, AzureSqlDatabaseReplicationAdapter>
2424
{
2525
/// <summary>
26-
/// Gets or sets the name of the database server to use.
26+
/// Gets or sets the name of the Azure SQL Server to use.
2727
/// </summary>
2828
[Parameter(Mandatory = true,
2929
ValueFromPipelineByPropertyName = true,
3030
Position = 1,
31-
HelpMessage = "The name of the Azure SQL Database Server the database to be copied is in.")]
31+
HelpMessage = "The name of the Azure SQL Server the database to be copied is in.")]
3232
[ValidateNotNullOrEmpty]
3333
public string ServerName { get; set; }
3434

3535
/// <summary>
3636
/// Initializes the adapter
3737
/// </summary>
38-
/// <param name="subscription"></param>
39-
/// <returns></returns>
38+
/// <param name="subscription">The Azure Subscription</param>
39+
/// <returns>A replication Adapter object</returns>
4040
protected override AzureSqlDatabaseReplicationAdapter InitModelAdapter(Azure.Common.Authentication.Models.AzureSubscription subscription)
4141
{
4242
return new AzureSqlDatabaseReplicationAdapter(Profile, subscription);

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/AzureSqlDatabaseSecondaryCmdletBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
16-
using System.Management.Automation;
1715
using Microsoft.Azure.Commands.Sql.Common;
1816
using Microsoft.Azure.Commands.Sql.Replication.Model;
1917
using Microsoft.Azure.Commands.Sql.ReplicationLink.Services;
18+
using System.Collections.Generic;
19+
using System.Management.Automation;
2020

2121
namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
2222
{
2323
public abstract class AzureSqlDatabaseSecondaryCmdletBase : AzureSqlCmdletBase<IEnumerable<AzureReplicationLinkModel>, AzureSqlDatabaseReplicationAdapter>
2424
{
2525
/// <summary>
26-
/// Gets or sets the name of the database server to use.
26+
/// Gets or sets the name of the Azure SQL Server to use.
2727
/// </summary>
2828
[Parameter(Mandatory = true,
2929
ValueFromPipelineByPropertyName = true,
3030
Position = 1,
31-
HelpMessage = "The name of the Azure SQL Database Server the database to be copied is in.")]
31+
HelpMessage = "The name of the Azure SQL Server the database to be replicated is in.")]
3232
[ValidateNotNullOrEmpty]
3333
public string ServerName { get; set; }
3434

3535
/// <summary>
3636
/// Initializes the adapter
3737
/// </summary>
3838
/// <param name="subscription"></param>
39-
/// <returns></returns>
39+
/// <returns>A replication Adapter object</returns>
4040
protected override AzureSqlDatabaseReplicationAdapter InitModelAdapter(Azure.Common.Authentication.Models.AzureSubscription subscription)
4141
{
4242
return new AzureSqlDatabaseReplicationAdapter(Profile, subscription);

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/GetAzureSqlDatabaseReplicationLink.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
2525
public class GetAzureSqlDatabaseReplicationLink : AzureSqlDatabaseSecondaryCmdletBase
2626
{
2727
/// <summary>
28-
/// ParameterSet to get all Replication Links for a given Azure Sql Database
28+
/// ParameterSet to get all Replication Links for a given Azure SQL Database
2929
/// </summary>
3030
internal const string ByDatabaseName = "ByDatabaseName";
3131

3232
/// <summary>
33-
/// ParameterSet to get a Replication Link by its partner Server Name
33+
/// ParameterSet to get a Replication Link by its partner Azure SQL Server Name
3434
/// </summary>
3535
internal const string ByPartnerServerName = "ByPartnerServerName";
3636

3737
/// <summary>
38-
/// Gets or sets the name of the Azure Sql Database to retrieve links for.
38+
/// Gets or sets the name of the Azure SQL Database to retrieve links for.
3939
/// </summary>
4040
[Parameter(Mandatory = true,
4141
ValueFromPipelineByPropertyName = true,
@@ -54,12 +54,12 @@ public class GetAzureSqlDatabaseReplicationLink : AzureSqlDatabaseSecondaryCmdle
5454
public string PartnerResourceGroupName { get; set; }
5555

5656
/// <summary>
57-
/// Gets or sets the name of the server that has the Azure SQL Database partner.
57+
/// Gets or sets the name of the Azure SQL Server that has the Azure SQL Database partner.
5858
/// </summary>
5959
[Parameter(Mandatory = false,
6060
ParameterSetName = ByPartnerServerName,
6161
ValueFromPipelineByPropertyName = false,
62-
HelpMessage = "The name of the server that has the Azure SQL Database partner.")]
62+
HelpMessage = "The name of the Azure SQL Server that has the Azure SQL Database partner.")]
6363
[ValidateNotNullOrEmpty]
6464
public string PartnerServerName { get; set; }
6565

@@ -95,7 +95,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
9595
}
9696

9797
/// <summary>
98-
/// No changes to persist to server
98+
/// No changes to persist to Azure SQL Server
9999
/// </summary>
100100
/// <param name="entity">The output of apply user input to model</param>
101101
/// <returns>The input entity</returns>

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/NewAzureSqlDatabaseCopy.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Hyak.Common;
16+
using Microsoft.Azure.Commands.Sql.Properties;
17+
using Microsoft.Azure.Commands.Sql.Replication.Model;
1518
using System.Collections.Generic;
1619
using System.Linq;
1720
using System.Management.Automation;
18-
using Hyak.Common;
19-
using Microsoft.Azure.Commands.Sql.Replication.Model;
20-
using Microsoft.Azure.Commands.Sql.Properties;
2121

2222
namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
2323
{
2424
/// <summary>
25-
/// Cmdlet to create a new Azure Sql Database Copy
25+
/// Cmdlet to create a new Azure SQL Database Copy
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.New, "AzureSqlDatabaseCopy",
2828
ConfirmImpact = ConfirmImpact.Low)]
@@ -55,10 +55,10 @@ public class NewAzureSqlDatabaseCopy : AzureSqlDatabaseCopyCmdletBase
5555
public string ElasticPoolName { get; set; }
5656

5757
/// <summary>
58-
/// Gets or sets the tags associated with the Azure Sql Database Copy
58+
/// Gets or sets the tags associated with the Azure SQL Database Copy
5959
/// </summary>
6060
[Parameter(Mandatory = false,
61-
HelpMessage = "The tags to associate with the Azure Sql Database Copy")]
61+
HelpMessage = "The tags to associate with the Azure SQL Database Copy")]
6262
public Dictionary<string, string> Tags { get; set; }
6363

6464
/// <summary>
@@ -70,18 +70,18 @@ public class NewAzureSqlDatabaseCopy : AzureSqlDatabaseCopyCmdletBase
7070
public string CopyResourceGroupName { get; set; }
7171

7272
/// <summary>
73-
/// Gets or sets the name of the server of the copy.
73+
/// Gets or sets the name of the Azure SQL Server of the copy.
7474
/// </summary>
7575
[Parameter(Mandatory = false,
76-
HelpMessage = "The name of the Azure Sql Database Server of the copy.")]
76+
HelpMessage = "The name of the Azure SQL Server of the copy.")]
7777
[ValidateNotNullOrEmpty]
7878
public string CopyServerName { get; set; }
7979

8080
/// <summary>
8181
/// Gets or sets the name of the source database copy.
8282
/// </summary>
8383
[Parameter(Mandatory = true,
84-
HelpMessage = "The name of the Azure Sql Database copy.")]
84+
HelpMessage = "The name of the Azure SQL Database copy.")]
8585
[ValidateNotNullOrEmpty]
8686
public string CopyDatabaseName { get; set; }
8787

@@ -113,8 +113,8 @@ protected override IEnumerable<AzureSqlDatabaseCopyModel> GetEntity()
113113

114114
// The database already exists
115115
throw new PSArgumentException(
116-
string.Format(Resources.DatabaseNameExists, this.DatabaseName, this.ServerName),
117-
"DatabaseName");
116+
string.Format(Resources.DatabaseNameExists, this.CopyDatabaseName, copyServerName),
117+
"CopyDatabaseName");
118118
}
119119

120120
/// <summary>
@@ -128,7 +128,7 @@ protected override IEnumerable<AzureSqlDatabaseCopyModel> ApplyUserInputToModel(
128128
string copyServer = string.IsNullOrWhiteSpace(CopyServerName) ? ServerName : CopyServerName;
129129

130130
string location = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName);
131-
string copyLocation = ModelAdapter.GetServerLocation(copyResourceGroup, copyServer);
131+
string copyLocation = copyServer.Equals(ServerName) ? location : ModelAdapter.GetServerLocation(copyResourceGroup, copyServer);
132132
List<Model.AzureSqlDatabaseCopyModel> newEntity = new List<AzureSqlDatabaseCopyModel>();
133133
newEntity.Add(new AzureSqlDatabaseCopyModel()
134134
{

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/NewAzureSqlDatabaseSecondary.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Hyak.Common;
16+
using Microsoft.Azure.Commands.Sql.Properties;
17+
using Microsoft.Azure.Commands.Sql.Replication.Model;
1518
using System.Collections.Generic;
1619
using System.Linq;
1720
using System.Management.Automation;
18-
using Hyak.Common;
19-
using Microsoft.Azure.Commands.Sql.Replication.Model;
20-
using Microsoft.Azure.Commands.Sql.Properties;
2121

2222
namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
2323
{
2424
/// <summary>
25-
/// Cmdlet to create a new Azure Sql Database Secondary and Replication Link
25+
/// Cmdlet to create a new Azure SQL Database Secondary and Replication Link
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.New, "AzureSqlDatabaseSecondary",
2828
ConfirmImpact = ConfirmImpact.Low)]
@@ -55,10 +55,10 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
5555
public string SecondaryElasticPoolName { get; set; }
5656

5757
/// <summary>
58-
/// Gets or sets the tags to associate with the Azure Sql Database Replication Link
58+
/// Gets or sets the tags to associate with the Azure SQL Database Replication Link
5959
/// </summary>
6060
[Parameter(Mandatory = false,
61-
HelpMessage = "The tags to associate with the Azure Sql Database Replication Link")]
61+
HelpMessage = "The tags to associate with the Azure SQL Database Replication Link")]
6262
public Dictionary<string, string> Tags { get; set; }
6363

6464
/// <summary>
@@ -70,10 +70,10 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
7070
public string PartnerResourceGroupName { get; set; }
7171

7272
/// <summary>
73-
/// Gets or sets the name of the server of the secondary.
73+
/// Gets or sets the name of the Azure SQL Server of the secondary.
7474
/// </summary>
7575
[Parameter(Mandatory = true,
76-
HelpMessage = "The name of the Azure Sql Database Server to create secondary in.")]
76+
HelpMessage = "The name of the Azure SQL Server to create secondary in.")]
7777
[ValidateNotNullOrEmpty]
7878
public string PartnerServerName { get; set; }
7979

@@ -91,7 +91,7 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
9191
/// <returns>The list of entities</returns>
9292
protected override IEnumerable<AzureReplicationLinkModel> GetEntity()
9393
{
94-
// We try to get the database. Since this is a geodr operation, we don't want the secondary to already exist
94+
// We try to get the database. Since this is a create secondary database operation, we don't want the secondary database to already exist
9595
try
9696
{
9797
ModelAdapter.GetDatabase(this.PartnerResourceGroupName, this.PartnerServerName, this.DatabaseName);
@@ -110,7 +110,7 @@ protected override IEnumerable<AzureReplicationLinkModel> GetEntity()
110110

111111
// The database already exists
112112
throw new PSArgumentException(
113-
string.Format(Resources.DatabaseNameExists, this.DatabaseName, this.ServerName),
113+
string.Format(Resources.DatabaseNameExists, this.DatabaseName, this.PartnerServerName),
114114
"DatabaseName");
115115
}
116116

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/RemoveAzureSqlDatabaseSecondary.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Sql.Replication.Model;
1615
using Microsoft.Azure.Commands.Sql.Properties;
16+
using Microsoft.Azure.Commands.Sql.Replication.Model;
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Globalization;
@@ -22,18 +22,12 @@
2222
namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
2323
{
2424
[Cmdlet(VerbsCommon.Remove, "AzureSqlDatabaseSecondary",
25-
DefaultParameterSetName = ByPartnerServerName,
2625
SupportsShouldProcess = true,
2726
ConfirmImpact = ConfirmImpact.High)]
2827
public class RemoveAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
2928
{
3029
/// <summary>
31-
/// ParameterSet to get a Replication Link by its Partner Server Name
32-
/// </summary>
33-
internal const string ByPartnerServerName = "ByPartnerServerName";
34-
35-
/// <summary>
36-
/// Gets or sets the name of the primary Replication Link to remove.
30+
/// Gets or sets the name of the primary Azure SQL Database with the replication link to remove.
3731
/// </summary>
3832
[Parameter(Mandatory = true,
3933
ValueFromPipelineByPropertyName = true,
@@ -43,22 +37,20 @@ public class RemoveAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBa
4337
public string DatabaseName { get; set; }
4438

4539
/// <summary>
46-
/// Gets or sets the name of the resource group of the partner.
40+
/// Gets or sets the name of the partner resource group.
4741
/// </summary>
4842
[Parameter(Mandatory = true,
49-
ParameterSetName = ByPartnerServerName,
5043
ValueFromPipelineByPropertyName = true,
5144
HelpMessage = "The name of the resource group of the secondary.")]
5245
[ValidateNotNullOrEmpty]
5346
public string PartnerResourceGroupName { get; set; }
5447

5548
/// <summary>
56-
/// Gets or sets the name of the server of the partner.
49+
/// Gets or sets the name of the partner Azure SQL Server.
5750
/// </summary>
5851
[Parameter(Mandatory = true,
59-
ParameterSetName = ByPartnerServerName,
6052
ValueFromPipelineByPropertyName = true,
61-
HelpMessage = "The name of the Azure Sql Database Server of the secondary.")]
53+
HelpMessage = "The name of the Azure SQL Server of the secondary.")]
6254
[ValidateNotNullOrEmpty]
6355
public string PartnerServerName { get; set; }
6456

@@ -84,7 +76,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
8476
}
8577

8678
/// <summary>
87-
/// No changes to persist to server
79+
/// No changes to persist to Azure SQL Server
8880
/// </summary>
8981
/// <param name="entity">The output of apply user input to model</param>
9082
/// <returns>The input entity</returns>

src/ResourceManager/Sql/Commands.Sql/Replication/Model/AllowConnections.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ public enum AllowConnections
2828
/// Readable Secondary
2929
/// </summary>
3030
All = 1
31-
32-
// Not yet supported
33-
// ReadOnly = 2
3431
}
3532
}
3633

0 commit comments

Comments
 (0)