@@ -89,10 +89,10 @@ public class NewAzureSqlDatabaseServerContext : AzurePSCmdlet
89
89
/// <summary>
90
90
/// Gets or sets the management site data connection fully qualified server name.
91
91
/// </summary>
92
- [ Parameter ( Mandatory = true , Position = 0 ,
92
+ [ Parameter ( Mandatory = true , Position = 0 ,
93
93
ParameterSetName = FullyQualifiedServerNameWithSqlAuthParamSet ,
94
94
HelpMessage = "The fully qualified server name" ) ]
95
- [ Parameter ( Mandatory = true , Position = 0 ,
95
+ [ Parameter ( Mandatory = true , Position = 0 ,
96
96
ParameterSetName = FullyQualifiedServerNameWithCertAuthParamSet ,
97
97
HelpMessage = "The fully qualified server name" ) ]
98
98
[ ValidateNotNull ]
@@ -109,13 +109,13 @@ public class NewAzureSqlDatabaseServerContext : AzurePSCmdlet
109
109
/// <summary>
110
110
/// Gets or sets the server credentials
111
111
/// </summary>
112
- [ Parameter ( Mandatory = true , Position = 1 ,
112
+ [ Parameter ( Mandatory = true , Position = 1 ,
113
113
ParameterSetName = ServerNameWithSqlAuthParamSet ,
114
114
HelpMessage = "The credentials for the server" ) ]
115
- [ Parameter ( Mandatory = true , Position = 1 ,
115
+ [ Parameter ( Mandatory = true , Position = 1 ,
116
116
ParameterSetName = FullyQualifiedServerNameWithSqlAuthParamSet ,
117
117
HelpMessage = "The credentials for the server" ) ]
118
- [ Parameter ( Mandatory = true , Position = 1 ,
118
+ [ Parameter ( Mandatory = true , Position = 1 ,
119
119
ParameterSetName = ManageUrlWithSqlAuthParamSet ,
120
120
HelpMessage = "The credentials for the server" ) ]
121
121
[ ValidateNotNull ]
@@ -124,10 +124,10 @@ public class NewAzureSqlDatabaseServerContext : AzurePSCmdlet
124
124
/// <summary>
125
125
/// Gets or sets whether or not the current subscription should be used for authentication
126
126
/// </summary>
127
- [ Parameter ( Mandatory = true , Position = 1 ,
127
+ [ Parameter ( Mandatory = true , Position = 1 ,
128
128
ParameterSetName = ServerNameWithCertAuthParamSet ,
129
129
HelpMessage = "Use certificate authentication" ) ]
130
- [ Parameter ( Mandatory = true , Position = 1 ,
130
+ [ Parameter ( Mandatory = true , Position = 1 ,
131
131
ParameterSetName = FullyQualifiedServerNameWithCertAuthParamSet ,
132
132
HelpMessage = "Use certificate authentication" ) ]
133
133
public SwitchParameter UseSubscription { get ; set ; }
@@ -140,13 +140,6 @@ public class NewAzureSqlDatabaseServerContext : AzurePSCmdlet
140
140
HelpMessage = "The subscription to use, or uses the current subscription if not specified" ) ]
141
141
public string SubscriptionName { get ; set ; }
142
142
143
- /// <summary>
144
- /// Switch to indiciate the the server is an ESA server
145
- /// </summary>
146
- [ Parameter ( Mandatory = false ,
147
- HelpMessage = "Indicates the server version being targeted. Valid values [2.0, 12.0]. Default = 2.0" ) ]
148
- public float Version { get ; set ; }
149
-
150
143
#endregion
151
144
152
145
#region Current Subscription Management
@@ -188,63 +181,20 @@ internal IServerDataServiceContext GetServerDataServiceBySqlAuth(
188
181
IServerDataServiceContext context = null ;
189
182
Guid sessionActivityId = Guid . NewGuid ( ) ;
190
183
191
- if ( this . MyInvocation . BoundParameters . ContainsKey ( "Version" ) )
184
+ try
192
185
{
193
- if ( this . Version == 12.0f )
194
- {
195
- try
196
- {
197
- context = new TSqlConnectionContext (
198
- sessionActivityId ,
199
- manageUrl . Host ,
200
- credentials . UserName ,
201
- credentials . Password ) ;
202
- }
203
- catch ( Exception ex )
204
- {
205
- SqlDatabaseExceptionHandler . WriteErrorDetails (
206
- this ,
207
- sessionActivityId . ToString ( ) ,
208
- ex ) ;
209
-
210
- // The context is not in an valid state because of the error, set the context
211
- // back to null.
212
- context = null ;
213
- }
214
- }
215
- else
216
- {
217
- try
218
- {
219
- context = ServerDataServiceSqlAuth . Create (
220
- managementServiceUri ,
221
- sessionActivityId ,
222
- credentials ,
223
- serverName ) ;
224
-
225
- // Retrieve $metadata to verify model version compatibility
226
- XDocument metadata = ( ( ServerDataServiceSqlAuth ) context ) . RetrieveMetadata ( ) ;
227
- XDocument filteredMetadata = DataConnectionUtility . FilterMetadataDocument ( metadata ) ;
228
- string metadataHash = DataConnectionUtility . GetDocumentHash ( filteredMetadata ) ;
229
- if ( ! ( ( ServerDataServiceSqlAuth ) context ) . metadataHashes . Any ( knownHash => metadataHash == knownHash ) )
230
- {
231
- this . WriteWarning ( Resources . WarningModelOutOfDate ) ;
232
- }
233
-
234
- ( ( ServerDataServiceSqlAuth ) context ) . MergeOption = MergeOption . PreserveChanges ;
235
- }
236
- catch ( Exception ex )
237
- {
238
- SqlDatabaseExceptionHandler . WriteErrorDetails (
239
- this ,
240
- sessionActivityId . ToString ( ) ,
241
- ex ) ;
242
-
243
- // The context is not in an valid state because of the error, set the context
244
- // back to null.
245
- context = null ;
246
- }
247
- }
186
+ context = SqlAuthContextFactory . GetContext ( this , serverName , manageUrl , credentials , sessionActivityId , managementServiceUri ) ;
187
+ }
188
+ catch ( Exception ex )
189
+ {
190
+ SqlDatabaseExceptionHandler . WriteErrorDetails (
191
+ this ,
192
+ sessionActivityId . ToString ( ) ,
193
+ ex ) ;
194
+
195
+ // The context is not in an valid state because of the error, set the context
196
+ // back to null.
197
+ context = null ;
248
198
}
249
199
250
200
return context ;
0 commit comments