@@ -45,15 +45,15 @@ public class NewAzureSqlSyncAgent : AzureSqlSyncAgentCmdletBase
45
45
/// <summary>
46
46
/// Gets or sets the name of the server on which syncDB is hosted
47
47
/// </summary>
48
- [ Parameter ( Mandatory = true ,
48
+ [ Parameter ( Mandatory = false ,
49
49
HelpMessage = "The server on which syncDB is hosted." ) ]
50
50
[ ValidateNotNullOrEmpty ]
51
51
public string SyncDatabaseServerName { get ; set ; }
52
52
53
53
/// <summary>
54
54
/// Gets or sets the name of the resource group the syncDB belongs to
55
55
/// </summary>
56
- [ Parameter ( Mandatory = true ,
56
+ [ Parameter ( Mandatory = false ,
57
57
HelpMessage = "The resource group syncDB belongs to." ) ]
58
58
[ ValidateNotNullOrEmpty ]
59
59
public string SyncDatabaseResourceGroupName { get ; set ; }
@@ -107,10 +107,17 @@ protected override IEnumerable<AzureSqlSyncAgentModel> ApplyUserInputToModel(IEn
107
107
SyncAgentName = this . SyncAgentName
108
108
} ) ;
109
109
110
- if ( MyInvocation . BoundParameters . ContainsKey ( "SyncDatabaseResourceGroupName" )
111
- && MyInvocation . BoundParameters . ContainsKey ( "SyncDatabaseServerName" )
112
- && MyInvocation . BoundParameters . ContainsKey ( "SyncDatabaseName" ) )
110
+ if ( MyInvocation . BoundParameters . ContainsKey ( "SyncDatabaseName" ) )
113
111
{
112
+ if ( ! MyInvocation . BoundParameters . ContainsKey ( "SyncDatabaseResourceGroupName" ) )
113
+ {
114
+ this . SyncDatabaseResourceGroupName = this . ResourceGroupName ;
115
+ }
116
+ if ( ! MyInvocation . BoundParameters . ContainsKey ( "SyncDatabaseServerName" ) )
117
+ {
118
+ this . SyncDatabaseServerName = this . ServerName ;
119
+ }
120
+ // "/subscriptions/{id}/" will be added in AzureSqlDataSyncCommunicator
114
121
this . syncDatabaseId = string . Format ( "resourceGroups/{0}/providers/Microsoft.Sql/servers/{1}/databases/{2}" ,
115
122
this . SyncDatabaseResourceGroupName , this . SyncDatabaseServerName , this . SyncDatabaseName ) ;
116
123
}
0 commit comments