Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Sql/Sql.Test/Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.Azure.KeyVault.WebKey" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.20.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.41.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.42.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release
* Added UsePrivateLinkConnection to `New-AzSqlSyncGroup`, `Update-AzSqlSyncGroup`, `New-AzSqlSyncMember` and `Update-AzSqlSyncMember`
* Added SyncMemberAzureDatabaseResourceId to `New-AzSqlSyncMember` and `Update-AzSqlSyncMember`

## Version 2.6.1
* Enhance performance of:
Expand Down
10 changes: 9 additions & 1 deletion src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Linq;
using Microsoft.Azure.Commands.Sql.DataSync.Model;
using Microsoft.Azure.Management.Sql.Models;
using Hyak.Common;
using Microsoft.Rest.Azure;
using Newtonsoft.Json.Linq;
using System.IO;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
Expand Down Expand Up @@ -95,6 +95,12 @@ public class NewAzureSqlSyncGroup : AzureSqlSyncGroupCmdletBase
[ValidateNotNullOrEmpty]
public string SchemaFile { get; set; }

/// <summary>
/// Gets or sets if private link should be used
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Use a private link connection when connecting to the hub of this sync group.")]
public SwitchParameter UsePrivateLinkConnection { get; set; }

/// <summary>
/// The id of database used to store sync related metadata
/// </summary>
Expand Down Expand Up @@ -153,6 +159,8 @@ protected override IEnumerable<AzureSqlSyncGroupModel> ApplyUserInputToModel(IEn
newModel.IntervalInSeconds = this.IntervalInSeconds;
}

newModel.UsePrivateLinkConnection = UsePrivateLinkConnection.IsPresent;

if (MyInvocation.BoundParameters.ContainsKey("SyncDatabaseResourceGroupName")
&& MyInvocation.BoundParameters.ContainsKey("SyncDatabaseServerName")
&& MyInvocation.BoundParameters.ContainsKey("SyncDatabaseName"))
Expand Down
32 changes: 31 additions & 1 deletion src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using Hyak.Common;
using Microsoft.Rest.Azure;
using Microsoft.Azure.Commands.Sql.DataSync.Model;
using Microsoft.Azure.Commands.Sql.Properties;
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
Expand Down Expand Up @@ -146,6 +146,24 @@ public class NewAzureSqlSyncMember : AzureSqlSyncMemberCmdletBase
[ValidateSet("Bidirectional", "OneWayMemberToHub", "OneWayHubToMember", IgnoreCase = true)]
public string SyncDirection { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to use private link connection
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Use a private link connection when connecting to this sync member.")]
public SwitchParameter UsePrivateLinkConnection { get; set; }

/// <summary>
/// Gets or sets the sync member resource Id
/// </summary>
/// <value>
/// The sync member database id (only for sync member using Azure SQL Database), e.g. "subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup01}/servers/{syncMemberServer01}/databases/{syncMemberDatabaseName01}"
/// </value>
/// <remarks>
/// This needs to be a sync member sql azure database id (i.e. full arm uri) so that we can validate calling user's R/W access to this database via RBAC.
/// </remarks>
[Parameter(Mandatory = false, HelpMessage = "The resource ID for the sync member database, used if UsePrivateLinkConnection is set to true.")]
public string SyncMemberAzureDatabaseResourceId { get; set; }

/// <summary>
/// The id of the sync agent which is connected by the on-premises SQL server.
/// </summary>
Expand Down Expand Up @@ -198,6 +216,18 @@ protected override IEnumerable<AzureSqlSyncMemberModel> ApplyUserInputToModel(IE
SyncDirection = this.SyncDirection,
MemberDatabaseType = this.MemberDatabaseType
};

if (UsePrivateLinkConnection.IsPresent)
{
if (!MyInvocation.BoundParameters.ContainsKey(nameof(SyncMemberAzureDatabaseResourceId)))
{
throw new PSArgumentException(
Microsoft.Azure.Commands.Sql.Properties.Resources.SyncMemberIdRequired, nameof(SyncMemberAzureDatabaseResourceId));
}

newModel.UsePrivateLinkConnection = true;
newModel.SyncMemberAzureDatabaseResourceId = this.SyncMemberAzureDatabaseResourceId;
}

if(ParameterSetName == AzureSqlSet)
{
Expand Down
11 changes: 11 additions & 0 deletions src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public class UpdateAzureSqlSyncGroup : AzureSqlSyncGroupCmdletBase
[Parameter(Mandatory = false, HelpMessage = "The path of the schema file.")]
public string SchemaFile { get; set; }

/// <summary>
/// Gets or sets if private link should be used
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Whether to use a private link connection when connecting to the hub of this sync group.")]
public bool UsePrivateLinkConnection { get; set; }

/// <summary>
/// Get the entities from the service
/// </summary>
Expand All @@ -81,6 +87,11 @@ protected override IEnumerable<AzureSqlSyncGroupModel> ApplyUserInputToModel(IEn
newModel.IntervalInSeconds = this.IntervalInSeconds;
}

if (MyInvocation.BoundParameters.ContainsKey(nameof(UsePrivateLinkConnection)))
{
newModel.UsePrivateLinkConnection = this.UsePrivateLinkConnection;
}

if (MyInvocation.BoundParameters.ContainsKey("DatabaseCredential"))
{
newModel.HubDatabaseUserName = this.DatabaseCredential.UserName;
Expand Down
33 changes: 31 additions & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,27 @@ public class UpdateAzureSqlSyncMember : AzureSqlSyncMemberCmdletBase
/// <summary>
/// Gets or sets the credential (username and password) of the Azure SQL Database.
/// </summary>
[Parameter(Mandatory = true, HelpMessage = "The credential (username and password) of the Azure SQL Database.")]
[ValidateNotNull]
[Parameter(Mandatory = false, HelpMessage = "The credential (username and password) of the Azure SQL Database.")]
public PSCredential MemberDatabaseCredential { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to use private link connection
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Whether to use private link when connecting to this sync member.")]
public bool? UsePrivateLinkConnection { get; set; }

/// <summary>
/// Gets or sets the sync member resource Id
/// </summary>
/// <value>
/// The sync member database id (only for sync member using Azure SQL Database), e.g. "subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup01}/servers/{syncMemberServer01}/databases/{syncMemberDatabaseName01}"
/// </value>
/// <remarks>
/// This needs to be a sync member sql azure database id (i.e. full arm uri) so that we can validate calling user's R/W access to this database via RBAC.
/// </remarks>
[Parameter(Mandatory = false, HelpMessage = "The resource ID for the sync member database, used if UsePrivateLinkConnection is set to true.")]
public string SyncMemberAzureDatabaseResourceId { get; set; }

/// <summary>
/// Get the entities from the service
/// </summary>
Expand All @@ -64,6 +81,18 @@ protected override IEnumerable<AzureSqlSyncMemberModel> ApplyUserInputToModel(IE
{
AzureSqlSyncMemberModel newModel = model.First();

if (MyInvocation.BoundParameters.ContainsKey(nameof(UsePrivateLinkConnection)))
{
if (this.UsePrivateLinkConnection.GetValueOrDefault() && !MyInvocation.BoundParameters.ContainsKey(nameof(SyncMemberAzureDatabaseResourceId)))
{
throw new PSArgumentException(
Microsoft.Azure.Commands.Sql.Properties.Resources.SyncMemberIdRequired, nameof(SyncMemberAzureDatabaseResourceId));
}

newModel.UsePrivateLinkConnection = this.UsePrivateLinkConnection;
newModel.SyncMemberAzureDatabaseResourceId = this.SyncMemberAzureDatabaseResourceId;
}

if (MyInvocation.BoundParameters.ContainsKey("MemberDatabaseCredential"))
{
newModel.MemberDatabaseUserName = this.MemberDatabaseCredential.UserName;
Expand Down
22 changes: 14 additions & 8 deletions src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Security;
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
using Microsoft.Azure.Management.Sql.Models;

namespace Microsoft.Azure.Commands.Sql.DataSync.Model
{
Expand Down Expand Up @@ -88,6 +88,11 @@ public class AzureSqlSyncGroupModel
/// </summary>
public AzureSqlSyncGroupSchemaModel Schema { get; set; }

/// <summary>
/// Gets or sets if private link connection should be used
/// </summary>
public bool? UsePrivateLinkConnection { get; set; }

/// <summary>
/// Construct AzureSqlSyncGroupModel
/// </summary>
Expand All @@ -110,13 +115,14 @@ public AzureSqlSyncGroupModel(string resourceGroupName, string serverName, strin
DatabaseName = databaseName;
ResourceId = syncGroup.Id;
SyncGroupName = syncGroup.Name;
IntervalInSeconds = syncGroup.Properties.Interval;
SyncDatabaseId = syncGroup.Properties.SyncDatabaseId;
HubDatabaseUserName = syncGroup.Properties.HubDatabaseUserName;
ConflictResolutionPolicy = syncGroup.Properties.ConflictResolutionPolicy == null ? null : syncGroup.Properties.ConflictResolutionPolicy.ToString();
SyncState = syncGroup.Properties.SyncState;
LastSyncTime = syncGroup.Properties.LastSyncTime;
Schema = syncGroup.Properties.Schema == null ? null : new AzureSqlSyncGroupSchemaModel(syncGroup.Properties.Schema);
IntervalInSeconds = syncGroup.Interval;
SyncDatabaseId = syncGroup.SyncDatabaseId;
HubDatabaseUserName = syncGroup.HubDatabaseUserName;
ConflictResolutionPolicy = syncGroup.ConflictResolutionPolicy == null ? null : syncGroup.ConflictResolutionPolicy.ToString();
SyncState = syncGroup.SyncState;
LastSyncTime = syncGroup.LastSyncTime;
Schema = syncGroup.Schema == null ? null : new AzureSqlSyncGroupSchemaModel(syncGroup.Schema);
UsePrivateLinkConnection = syncGroup.UsePrivateLinkConnection;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Collections.Generic;
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
using Microsoft.Azure.Management.Sql.Models;

namespace Microsoft.Azure.Commands.Sql.DataSync.Model
{
Expand Down Expand Up @@ -50,16 +50,16 @@ public AzureSqlSyncGroupSchemaColumnModel()
/// Construct AzureSqlSyncGroupSchemaColumnModel
/// </summary>
/// <param name="column">sync group schema column</param>
public AzureSqlSyncGroupSchemaColumnModel(SyncGroupSchemaColumn column)
public AzureSqlSyncGroupSchemaColumnModel(SyncGroupSchemaTableColumn column)
{
QuotedName = column != null ? column.QuotedName : null;
DataSize = column != null ? column.DataSize : null;
DataType = column != null ? column.DataType : null;
}

public SyncGroupSchemaColumn ToSyncGroupSchemaColumn()
public SyncGroupSchemaTableColumn ToSyncGroupSchemaColumn()
{
return new SyncGroupSchemaColumn
return new SyncGroupSchemaTableColumn
{
DataSize = this.DataSize,
DataType = this.DataType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Collections.Generic;
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
using Microsoft.Azure.Management.Sql.Models;

namespace Microsoft.Azure.Commands.Sql.DataSync.Model
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Collections.Generic;
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
using Microsoft.Azure.Management.Sql.Models;

namespace Microsoft.Azure.Commands.Sql.DataSync.Model
{
Expand Down Expand Up @@ -64,10 +64,10 @@ public AzureSqlSyncGroupSchemaTableModel(SyncGroupSchemaTable table)
/// <returns>The result SyncGroupSchemaTable</returns>
public SyncGroupSchemaTable ToSyncGroupSchemaTable()
{
List<SyncGroupSchemaColumn> syncGroupSchemaColumns = null;
List<SyncGroupSchemaTableColumn> syncGroupSchemaColumns = null;
if (Columns != null)
{
syncGroupSchemaColumns = new List<SyncGroupSchemaColumn>();
syncGroupSchemaColumns = new List<SyncGroupSchemaTableColumn>();
foreach (var column in Columns)
{
syncGroupSchemaColumns.Add(column.ToSyncGroupSchemaColumn());
Expand Down
30 changes: 21 additions & 9 deletions src/Sql/Sql/Data Sync/Model/AzureSqlSyncMemberModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// ----------------------------------------------------------------------------------

using System.Security;
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
using Microsoft.Azure.Management.Sql.Models;

namespace Microsoft.Azure.Commands.Sql.DataSync.Model
{
Expand Down Expand Up @@ -97,6 +97,16 @@ public class AzureSqlSyncMemberModel
/// </summary>
public string SyncState { get; set; }

/// <summary>
/// Gets or sets the sync member resource Id
/// </summary>
public string SyncMemberAzureDatabaseResourceId { get; set; }

/// <summary>
/// Gets or sets whether to use private link connection
/// </summary>
public bool? UsePrivateLinkConnection { get; set; }

/// <summary>
/// Construct AzureSqlSyncMemberModel
/// </summary>
Expand All @@ -120,14 +130,16 @@ public AzureSqlSyncMemberModel(string resourceGroup, string serverName, string d
ResourceId = syncMember.Id;
SyncGroupName = syncGroupName;
SyncMemberName = syncMember.Name;
SyncDirection = syncMember.Properties.SyncDirection == null ? null : syncMember.Properties.SyncDirection.ToString();
SyncAgentId = syncMember.Properties.SyncAgentId;
SqlServerDatabaseId = syncMember.Properties.SqlServerDatabaseId;
MemberServerName = syncMember.Properties.ServerName;
MemberDatabaseName = syncMember.Properties.DatabaseName;
MemberDatabaseUserName = syncMember.Properties.UserName;
MemberDatabaseType = syncMember.Properties.DatabaseType == null ? null : syncMember.Properties.DatabaseType.ToString();
SyncState = syncMember.Properties.SyncState;
SyncDirection = syncMember.SyncDirection == null ? null : syncMember.SyncDirection.ToString();
SyncAgentId = syncMember.SyncAgentId;
SqlServerDatabaseId = syncMember.SqlServerDatabaseId == null ? null : syncMember.SqlServerDatabaseId.ToString();
MemberServerName = syncMember.ServerName;
MemberDatabaseName = syncMember.DatabaseName;
MemberDatabaseUserName = syncMember.UserName;
MemberDatabaseType = syncMember.DatabaseType == null ? null : syncMember.DatabaseType.ToString();
SyncState = syncMember.SyncState;
UsePrivateLinkConnection = syncMember.UsePrivateLinkConnection;
SyncMemberAzureDatabaseResourceId = syncMember.SyncMemberAzureDatabaseResourceId;
}
}
}
Loading