Skip to content

Commit 4bdf6f0

Browse files
committed
Rebase master
1 parent f05fde1 commit 4bdf6f0

16 files changed

+1011
-72
lines changed

src/Sql/Sql/ManagedInstance/Cmdlet/GetAzureSqlManagedInstance.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ public class GetAzureSqlManagedInstance : ManagedInstanceCmdletBase
112112
[ValidateNotNullOrEmpty]
113113
public override string ResourceGroupName { get; set; }
114114

115+
/// <summary>
116+
/// Expand Active Directory Administrator Information on the Managed Instance
117+
/// </summary>
118+
[Parameter(Mandatory = false,
119+
HelpMessage = "Expand Active Directory Administrator Information on the server.")]
120+
public SwitchParameter ExpandActiveDirectoryAdministrators { get; set; }
121+
115122
/// <summary>
116123
/// Entry point for the cmdlet
117124
/// </summary>
@@ -148,25 +155,27 @@ protected override IEnumerable<AzureSqlManagedInstanceModel> GetEntity()
148155
{
149156
ICollection<AzureSqlManagedInstanceModel> results = new List<AzureSqlManagedInstanceModel>();
150157

158+
string expand = (this.ExpandActiveDirectoryAdministrators.IsPresent) ? "administrators/activeDirectory" : null;
159+
151160
if (ShouldGetByName(ResourceGroupName, Name))
152161
{
153162
results = new List<AzureSqlManagedInstanceModel>();
154-
results.Add(ModelAdapter.GetManagedInstance(this.ResourceGroupName, this.Name));
163+
results.Add(ModelAdapter.GetManagedInstance(this.ResourceGroupName, this.Name, expand));
155164
}
156165
else if (ShouldListByResourceGroup(ResourceGroupName, Name))
157166
{
158167
if (this.InstancePoolName != null)
159168
{
160-
results = ModelAdapter.ListManagedInstancesByInstancePool(this.ResourceGroupName, this.InstancePoolName);
169+
results = ModelAdapter.ListManagedInstancesByInstancePool(this.ResourceGroupName, this.InstancePoolName, expand);
161170
}
162171
else
163172
{
164-
results = ModelAdapter.ListManagedInstancesByResourceGroup(this.ResourceGroupName);
173+
results = ModelAdapter.ListManagedInstancesByResourceGroup(this.ResourceGroupName, expand);
165174
}
166175
}
167176
else
168177
{
169-
results = ModelAdapter.ListManagedInstances();
178+
results = ModelAdapter.ListManagedInstances(expand);
170179
}
171180

172181
return TopLevelWildcardFilter(ResourceGroupName, Name, results);

src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2929
using Microsoft.Azure.Commands.Sql.Instance_Pools.Services;
3030
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
31+
using System;
3132

3233
namespace Microsoft.Azure.Commands.Sql.ManagedInstance.Cmdlet
3334
{
@@ -120,8 +121,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
120121
/// <summary>
121122
/// Gets or sets the admin credential of the instance
122123
/// </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.")]
125125
public PSCredential AdministratorCredential { get; set; }
126126

127127
/// <summary>
@@ -335,11 +335,42 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
335335
[Parameter(HelpMessage = "Skip confirmation message for performing the action")]
336336
public SwitchParameter Force { get; set; }
337337

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+
338359
/// <summary>
339360
/// Overriding to add warning message
340361
/// </summary>
341362
public override void ExecuteCmdlet()
342363
{
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+
343374
if (this.IsParameterBound(c => c.InstancePool))
344375
{
345376
this.ResourceGroupName = this.InstancePool.ResourceGroupName;
@@ -462,8 +493,8 @@ public override void ExecuteCmdlet()
462493
Location = this.Location,
463494
ResourceGroupName = this.ResourceGroupName,
464495
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,
467498
Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
468499
Identity = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
469500
LicenseType = this.LicenseType,
@@ -483,7 +514,13 @@ public override void ExecuteCmdlet()
483514
InstancePoolName = this.InstancePoolName,
484515
MinimalTlsVersion = this.MinimalTlsVersion,
485516
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+
}
487524
});
488525
return newEntity;
489526
}

src/Sql/Sql/ManagedInstance/Model/AzureSqlManagedInstanceModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,10 @@ public class AzureSqlManagedInstanceModel
144144
/// Gets or sets the managed instance maintenance configuration id
145145
/// </summary>
146146
public string MaintenanceConfigurationId { get; set; }
147+
148+
/// <summary>
149+
/// Gets or sets the Azure SQL Managed Instance Active Directory administrator
150+
/// </summary>
151+
public Management.Sql.Models.ManagedInstanceExternalAdministrator Administrators { get; set; }
147152
}
148153
}

0 commit comments

Comments
 (0)