diff --git a/src/Sql/Sql.LegacySdk/Generated/Models/EncryptionProtectorProperties.cs b/src/Sql/Sql.LegacySdk/Generated/Models/EncryptionProtectorProperties.cs index 17744d2884e6..e0812a408012 100644 --- a/src/Sql/Sql.LegacySdk/Generated/Models/EncryptionProtectorProperties.cs +++ b/src/Sql/Sql.LegacySdk/Generated/Models/EncryptionProtectorProperties.cs @@ -69,7 +69,7 @@ public string Uri /// Optional. Gets or sets the Azure Sql Server Encryption /// Protector Key Rotation Status /// - public bool? AutoRotationEnabled + public bool? AutoKeyRotationEnabled { get { return this._isAutoRotationEnabled; } set { this._isAutoRotationEnabled = value; } diff --git a/src/Sql/Sql/Common/ResourceIdentityHelper.cs b/src/Sql/Sql/Common/ResourceIdentityHelper.cs index d46522662bda..ab5a69c56034 100644 --- a/src/Sql/Sql/Common/ResourceIdentityHelper.cs +++ b/src/Sql/Sql/Common/ResourceIdentityHelper.cs @@ -12,25 +12,41 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using System.Collections.Generic; + namespace Microsoft.Azure.Commands.Sql.Common { public enum ResourceIdentityType { - SystemAssigned + SystemAssigned, + UserAssigned, + None } public class ResourceIdentityHelper { - public static Management.Sql.Models.ResourceIdentity GetIdentityObjectFromType(bool assignIdentityIsPresent) + public static Management.Sql.Models.ResourceIdentity GetSystemAssignedIdentity() + { + Management.Sql.Models.ResourceIdentity identityResult = null; + + identityResult = new Management.Sql.Models.ResourceIdentity() + { + Type = ResourceIdentityType.SystemAssigned.ToString() + }; + + return identityResult; + } + + public static Management.Sql.Models.ResourceIdentity GetUserAssignedIdentity(List userAssignedIdentities) { Management.Sql.Models.ResourceIdentity identityResult = null; - if (assignIdentityIsPresent) + + identityResult = new Management.Sql.Models.ResourceIdentity() { - identityResult = new Management.Sql.Models.ResourceIdentity() - { - Type = ResourceIdentityType.SystemAssigned.ToString() - }; - } + Type = ResourceIdentityType.UserAssigned.ToString(), + // TODO + // Add user assigned identities. + }; return identityResult; } diff --git a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs index 76ea2b70d514..dee40495748e 100644 --- a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs +++ b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs @@ -327,16 +327,23 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase /// Id of the primary user assigned identity /// [Parameter(Mandatory = false, - HelpMessage = "The primary user assigned identity id")] + HelpMessage = "The primary user managed identity(UMI) id")] public string PrimaryUserAssignedIdentityId { get; set; } /// /// URI of the key to use for encryption /// [Parameter(Mandatory = false, - HelpMessage = "URI of the key to use for encryption")] + HelpMessage = "The Key Vault URI for encryption")] public string KeyId { get; set; } + // + /// List of user assigned identities. + /// + [Parameter(Mandatory = false, + HelpMessage = "List of user assigned identities")] + public List UserAssignedIdentities { get; set; } + /// /// Gets or sets whether or not to run this cmdlet in the background as a job /// @@ -479,7 +486,7 @@ public override void ExecuteCmdlet() AdministratorLogin = this.AdministratorCredential.UserName, AdministratorPassword = this.AdministratorCredential.Password, Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true), - Identity = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent), + Identity = this.AssignIdentity.Equals(ResourceIdentityType.SystemAssigned) ? ResourceIdentityHelper.GetSystemAssignedIdentity() : ResourceIdentityHelper.GetUserAssignedIdentity(this.UserAssignedIdentities), LicenseType = this.LicenseType, // `-StorageSizeInGB 0` as a parameter to this cmdlet means "use default". // For non-MI database, we can just pass in 0 and the server will treat 0 as default. diff --git a/src/Sql/Sql/ManagedInstance/Cmdlet/SetAzureSqlManagedInstance.cs b/src/Sql/Sql/ManagedInstance/Cmdlet/SetAzureSqlManagedInstance.cs index 9916f05df659..572887765151 100644 --- a/src/Sql/Sql/ManagedInstance/Cmdlet/SetAzureSqlManagedInstance.cs +++ b/src/Sql/Sql/ManagedInstance/Cmdlet/SetAzureSqlManagedInstance.cs @@ -186,14 +186,14 @@ public class SetAzureSqlManagedInstance : ManagedInstanceCmdletBase /// Id of the primary user assigned identity /// [Parameter(Mandatory = false, - HelpMessage = "The primary user assigned identity id")] + HelpMessage = "The primary user managed identity(UMI) id")] public string PrimaryUserAssignedIdentityId { get; set; } /// /// URI of the key to use for encryption /// [Parameter(Mandatory = false, - HelpMessage = "URI of the key to use for encryption")] + HelpMessage = "The Key Vault URI for encryption")] public string KeyId { get; set; } /// @@ -218,6 +218,13 @@ public class SetAzureSqlManagedInstance : ManagedInstanceCmdletBase HelpMessage = "The Maintenance configuration id for the Sql Azure Managed Instance.")] public string MaintenanceConfigurationId { get; set; } + // + /// List of user assigned identities. + /// + [Parameter(Mandatory = false, + HelpMessage = "List of user assigned identities")] + public List UserAssignedIdentities { get; set; } + /// /// Gets or sets whether or not to run this cmdlet in the background as a job /// @@ -301,7 +308,7 @@ protected override IEnumerable ApplyUserInputToMod PublicDataEndpointEnabled = this.PublicDataEndpointEnabled, ProxyOverride = this.ProxyOverride, Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true), - Identity = model.FirstOrDefault().Identity ?? ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent), + Identity = this.AssignIdentity.Equals(ResourceIdentityType.SystemAssigned) ? ResourceIdentityHelper.GetSystemAssignedIdentity() : ResourceIdentityHelper.GetUserAssignedIdentity(this.UserAssignedIdentities), InstancePoolName = this.InstancePoolName, MinimalTlsVersion = this.MinimalTlsVersion, MaintenanceConfigurationId = this.MaintenanceConfigurationId, diff --git a/src/Sql/Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs b/src/Sql/Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs index be22e23e1151..4c75adee5145 100644 --- a/src/Sql/Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs +++ b/src/Sql/Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs @@ -392,7 +392,7 @@ private AzureReplicationLinkModel CreateReplicationLinkModelFromResponse(string model.ServerName = serverName; model.DatabaseName = databaseName; model.AllowConnections = allowConnections; - model.Location = resp.Location; + model.Location = resp.PartnerLocation; model.PartnerLocation = resp.PartnerLocation; model.PercentComplete = resp.PercentComplete.ToString(); model.ReplicationState = resp.ReplicationState; diff --git a/src/Sql/Sql/Server/Cmdlet/NewAzureSqlServer.cs b/src/Sql/Sql/Server/Cmdlet/NewAzureSqlServer.cs index 03e4ff6c6728..ed6410294f19 100644 --- a/src/Sql/Sql/Server/Cmdlet/NewAzureSqlServer.cs +++ b/src/Sql/Sql/Server/Cmdlet/NewAzureSqlServer.cs @@ -93,16 +93,23 @@ public class NewAzureSqlServer : AzureSqlServerCmdletBase /// Id of the primary user assigned identity /// [Parameter(Mandatory = false, - HelpMessage = "The primary user assigned identity id")] + HelpMessage = "The primary user managed identity(UMI) id")] public string PrimaryUserAssignedIdentityId { get; set; } /// /// URI of the key to use for encryption /// [Parameter(Mandatory = false, - HelpMessage = "URI of the key to use for encryption")] + HelpMessage = "The Key Vault URI for encryption")] public string KeyId { get; set; } + // + /// List of user assigned identities. + /// + [Parameter(Mandatory = false, + HelpMessage = "List of user assigned identities")] + public List UserAssignedIdentities { get; set; } + /// /// Gets or sets whether or not to run this cmdlet in the background as a job /// @@ -167,7 +174,7 @@ public override void ExecuteCmdlet() SqlAdministratorPassword = this.SqlAdministratorCredentials.Password, SqlAdministratorLogin = this.SqlAdministratorCredentials.UserName, Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true), - Identity = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent), + Identity = this.AssignIdentity.Equals(ResourceIdentityType.SystemAssigned) ? ResourceIdentityHelper.GetSystemAssignedIdentity() : ResourceIdentityHelper.GetUserAssignedIdentity(this.UserAssignedIdentities), MinimalTlsVersion = this.MinimalTlsVersion, PublicNetworkAccess = this.PublicNetworkAccess, PrimaryUserAssignedIdentityId = this.PrimaryUserAssignedIdentityId, diff --git a/src/Sql/Sql/Server/Cmdlet/SetAzureSqlServer.cs b/src/Sql/Sql/Server/Cmdlet/SetAzureSqlServer.cs index 19b9d4b18b2c..73d882839081 100644 --- a/src/Sql/Sql/Server/Cmdlet/SetAzureSqlServer.cs +++ b/src/Sql/Sql/Server/Cmdlet/SetAzureSqlServer.cs @@ -87,16 +87,23 @@ public class SetAzureSqlServer : AzureSqlServerCmdletBase /// Id of the primary user assigned identity /// [Parameter(Mandatory = false, - HelpMessage = "The primary user assigned identity id")] + HelpMessage = "The primary user managed identity(UMI) id")] public string PrimaryUserAssignedIdentityId { get; set; } /// /// URI of the key to use for encryption /// [Parameter(Mandatory = false, - HelpMessage = "URI of the key to use for encryption")] + HelpMessage = "The Key Vault URI for encryption")] public string KeyId { get; set; } + // + /// List of user assigned identities. + /// + [Parameter(Mandatory = false, + HelpMessage = "List of user assigned identities")] + public List UserAssignedIdentities { get; set; } + /// /// Defines whether it is ok to skip the requesting of rule removal confirmation /// @@ -134,7 +141,7 @@ public class SetAzureSqlServer : AzureSqlServerCmdletBase Tags = TagsConversionHelper.ReadOrFetchTags(this, model.FirstOrDefault().Tags), ServerVersion = this.ServerVersion, Location = model.FirstOrDefault().Location, - Identity = model.FirstOrDefault().Identity ?? ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent), + Identity = this.AssignIdentity.Equals(ResourceIdentityType.SystemAssigned) ? ResourceIdentityHelper.GetSystemAssignedIdentity() : ResourceIdentityHelper.GetUserAssignedIdentity(this.UserAssignedIdentities), PublicNetworkAccess = this.PublicNetworkAccess, MinimalTlsVersion = this.MinimalTlsVersion, PrimaryUserAssignedIdentityId = this.PrimaryUserAssignedIdentityId, diff --git a/src/Sql/Sql/TransparentDataEncryption/Services/AzureSqlDatabaseTransparentDataEncryptionAdapter.cs b/src/Sql/Sql/TransparentDataEncryption/Services/AzureSqlDatabaseTransparentDataEncryptionAdapter.cs index 0c9b3d4fd071..73830cd1265f 100644 --- a/src/Sql/Sql/TransparentDataEncryption/Services/AzureSqlDatabaseTransparentDataEncryptionAdapter.cs +++ b/src/Sql/Sql/TransparentDataEncryption/Services/AzureSqlDatabaseTransparentDataEncryptionAdapter.cs @@ -194,7 +194,7 @@ private static AzureSqlServerTransparentDataEncryptionProtectorModel CreateEncry Model.EncryptionProtectorType type = Model.EncryptionProtectorType.ServiceManaged; Enum.TryParse(resp.Properties.ServerKeyType, true, out type); EncryptionProtector.Type = type; - EncryptionProtector.AutoRotationEnabled = resp.Properties.AutoRotationEnabled; + EncryptionProtector.AutoRotationEnabled = resp.Properties.AutoKeyRotationEnabled; if (type == Model.EncryptionProtectorType.AzureKeyVault) {