28
28
using Microsoft . WindowsAzure . Commands . Utilities . Common ;
29
29
using Microsoft . Azure . Commands . Sql . Instance_Pools . Services ;
30
30
using Microsoft . Azure . Management . Internal . Resources . Utilities . Models ;
31
+ using System ;
31
32
32
33
namespace Microsoft . Azure . Commands . Sql . ManagedInstance . Cmdlet
33
34
{
@@ -120,8 +121,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
120
121
/// <summary>
121
122
/// Gets or sets the admin credential of the instance
122
123
/// </summary>
123
- [ Parameter ( Mandatory = true , HelpMessage = "The SQL authentication credential of the instance." ) ]
124
- [ ValidateNotNull ]
124
+ [ Parameter ( Mandatory = false , HelpMessage = "The SQL authentication credential of the instance." ) ]
125
125
public PSCredential AdministratorCredential { get ; set ; }
126
126
127
127
/// <summary>
@@ -335,11 +335,42 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
335
335
[ Parameter ( HelpMessage = "Skip confirmation message for performing the action" ) ]
336
336
public SwitchParameter Force { get ; set ; }
337
337
338
+ /// <summary>
339
+ /// Enable Active Directory Only Authentication on the server
340
+ /// </summary>
341
+ [ Parameter ( Mandatory = false ,
342
+ HelpMessage = "Enable Active Directory Only Authentication on the server." ) ]
343
+ public SwitchParameter EnableActiveDirectoryOnlyAuthentication { get ; set ; }
344
+
345
+ /// <summary>
346
+ /// Azure Active Directory display name for a user or group
347
+ /// </summary>
348
+ [ Parameter ( Mandatory = false ,
349
+ HelpMessage = "Specifies the display name of the user, group or application which is the Azure Active Directory administrator for the server. This display name must exist in the active directory associated with the current subscription." ) ]
350
+ public string ExternalAdminName { get ; set ; }
351
+
352
+ /// <summary>
353
+ /// Azure Active Directory object id for a user, group or application
354
+ /// </summary>
355
+ [ Parameter ( Mandatory = false ,
356
+ HelpMessage = "Specifies the object ID of the user, group or application which is the Azure Active Directory administrator." ) ]
357
+ public Guid ? ExternalAdminSID { get ; set ; }
358
+
338
359
/// <summary>
339
360
/// Overriding to add warning message
340
361
/// </summary>
341
362
public override void ExecuteCmdlet ( )
342
363
{
364
+ if ( this . EnableActiveDirectoryOnlyAuthentication . IsPresent && this . ExternalAdminName == null )
365
+ {
366
+ throw new PSArgumentException ( Properties . Resources . MissingExternalAdmin , "ExternalAdminName" ) ;
367
+ }
368
+
369
+ if ( ! this . EnableActiveDirectoryOnlyAuthentication . IsPresent && this . AdministratorCredential == null )
370
+ {
371
+ throw new PSArgumentException ( Properties . Resources . MissingSQLAdministratorCredentials , "AdministratorCredential" ) ;
372
+ }
373
+
343
374
if ( this . IsParameterBound ( c => c . InstancePool ) )
344
375
{
345
376
this . ResourceGroupName = this . InstancePool . ResourceGroupName ;
@@ -462,8 +493,8 @@ public override void ExecuteCmdlet()
462
493
Location = this . Location ,
463
494
ResourceGroupName = this . ResourceGroupName ,
464
495
FullyQualifiedDomainName = this . Name ,
465
- AdministratorLogin = this . AdministratorCredential . UserName ,
466
- AdministratorPassword = this . AdministratorCredential . Password ,
496
+ AdministratorPassword = ( this . AdministratorCredential != null ) ? this . AdministratorCredential . Password : null ,
497
+ AdministratorLogin = ( this . AdministratorCredential != null ) ? this . AdministratorCredential . UserName : null ,
467
498
Tags = TagsConversionHelper . CreateTagDictionary ( Tag , validate : true ) ,
468
499
Identity = ResourceIdentityHelper . GetIdentityObjectFromType ( this . AssignIdentity . IsPresent ) ,
469
500
LicenseType = this . LicenseType ,
@@ -483,7 +514,13 @@ public override void ExecuteCmdlet()
483
514
InstancePoolName = this . InstancePoolName ,
484
515
MinimalTlsVersion = this . MinimalTlsVersion ,
485
516
BackupStorageRedundancy = this . BackupStorageRedundancy ,
486
- MaintenanceConfigurationId = this . MaintenanceConfigurationId
517
+ MaintenanceConfigurationId = this . MaintenanceConfigurationId ,
518
+ Administrators = new Management . Sql . Models . ManagedInstanceExternalAdministrator ( )
519
+ {
520
+ AzureADOnlyAuthentication = ( this . EnableActiveDirectoryOnlyAuthentication . IsPresent ) ? ( bool ? ) true : null ,
521
+ Login = this . ExternalAdminName ,
522
+ Sid = this . ExternalAdminSID
523
+ }
487
524
} ) ;
488
525
return newEntity ;
489
526
}
0 commit comments