/// <summary>
        /// Constructs the model to send to the update API
        /// </summary>
        /// <param name="model">The result of the get operation</param>
        /// <returns>The model to send to the update</returns>
        protected override IEnumerable <Model.AzureSqlServerModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlServerModel> model)
        {
            if (!Sql.Services.Util.ValidateServerName(this.ServerName))
            {
                throw new PSArgumentException(string.Format(Properties.Resources.ServerNameInvalid, this.ServerName), "ServerName");
            }

            // Construct a new entity so we only send the relevant data to the server
            List <Model.AzureSqlServerModel> updateData = new List <Model.AzureSqlServerModel>();

            updateData.Add(new Model.AzureSqlServerModel()
            {
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                SqlAdministratorPassword = this.SqlAdministratorPassword,
                Tags                          = TagsConversionHelper.ReadOrFetchTags(this, model.FirstOrDefault().Tags),
                ServerVersion                 = this.ServerVersion,
                Location                      = model.FirstOrDefault().Location,
                Identity                      = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent, this.IdentityType ?? null, UserAssignedIdentityId, model.FirstOrDefault().Identity),
                PublicNetworkAccess           = this.PublicNetworkAccess,
                MinimalTlsVersion             = this.MinimalTlsVersion,
                SqlAdministratorLogin         = model.FirstOrDefault().SqlAdministratorLogin,
                PrimaryUserAssignedIdentityId = this.PrimaryUserAssignedIdentityId ?? model.FirstOrDefault().PrimaryUserAssignedIdentityId,
                KeyId                         = this.KeyId
            });
            return(updateData);
        }
Esempio n. 2
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the server doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlServerModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlServerModel> model)
        {
            if (!Sql.Services.Util.ValidateServerName(this.ServerName))
            {
                throw new PSArgumentException(string.Format(Properties.Resources.ServerNameInvalid, this.ServerName), "ServerName");
            }

            List <Model.AzureSqlServerModel> newEntity = new List <Model.AzureSqlServerModel>();

            newEntity.Add(new Model.AzureSqlServerModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                ServerVersion            = this.ServerVersion,
                SqlAdministratorPassword = (this.SqlAdministratorCredentials != null) ? this.SqlAdministratorCredentials.Password : null,
                SqlAdministratorLogin    = (this.SqlAdministratorCredentials != null) ? this.SqlAdministratorCredentials.UserName : null,
                Tags                          = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                Identity                      = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent, this.IdentityType ?? null, UserAssignedIdentityId, null),
                MinimalTlsVersion             = this.MinimalTlsVersion,
                PublicNetworkAccess           = this.PublicNetworkAccess,
                RestrictOutboundNetworkAccess = this.RestrictOutboundNetworkAccess,
                PrimaryUserAssignedIdentityId = this.PrimaryUserAssignedIdentityId,
                KeyId                         = this.KeyId,
                Administrators                = new Management.Sql.Models.ServerExternalAdministrator()
                {
                    AzureADOnlyAuthentication = (this.EnableActiveDirectoryOnlyAuthentication.IsPresent) ? (bool?)true : null,
                    Login = this.ExternalAdminName,
                    Sid   = this.ExternalAdminSID
                }
            });
            return(newEntity);
        }
Esempio n. 3
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlManagedInstanceModel> model)
        {
            List <Model.AzureSqlManagedInstanceModel> newEntity = new List <Model.AzureSqlManagedInstanceModel>();

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (string.Equals(this.ParameterSetName, NewBySkuNameParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                Sku.Name = SkuName;
            }
            else if (string.Equals(this.ParameterSetName, NewByEditionAndComputeGenerationParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                string editionShort = Edition.Equals(Constants.GeneralPurposeEdition) ? "GP" : Edition.Equals(Constants.BusinessCriticalEdition) ? "BC" : "Unknown";
                Sku.Name = editionShort + "_" + ComputeGeneration;
            }

            newEntity.Add(new Model.AzureSqlManagedInstanceModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                FullyQualifiedDomainName = this.Name,
                AdministratorLogin       = this.AdministratorCredential.UserName,
                AdministratorPassword    = this.AdministratorCredential.Password,
                Tags            = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity        = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
                LicenseType     = this.LicenseType,
                StorageSizeInGB = this.StorageSizeInGB,
                SubnetId        = this.SubnetId,
                VCores          = this.VCore,
                Sku             = Sku,
                Collation       = this.Collation
            });
            return(newEntity);
        }
Esempio n. 4
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlManagedInstanceModel> model)
        {
            List <Model.AzureSqlManagedInstanceModel> newEntity = new List <Model.AzureSqlManagedInstanceModel>();

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (string.Equals(this.ParameterSetName, NewBySkuNameParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                Sku.Name = SkuName;
            }
            else if (string.Equals(this.ParameterSetName, NewByEditionAndComputeGenerationParameterSet, System.StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(this.ParameterSetName, NewByInstancePoolParentObjectParameterSet, System.StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(this.ParameterSetName, NewByInstancePoolResourceIdParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                string editionShort = AzureSqlManagedInstanceAdapter.GetInstanceSkuPrefix(Edition);
                Sku.Name = editionShort + "_" + ComputeGeneration;
            }

            newEntity.Add(new AzureSqlManagedInstanceModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                FullyQualifiedDomainName = this.Name,
                AdministratorPassword    = (this.AdministratorCredential != null) ? this.AdministratorCredential.Password : null,
                AdministratorLogin       = (this.AdministratorCredential != null) ? this.AdministratorCredential.UserName : null,
                Tags        = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity    = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent, this.IdentityType ?? null, UserAssignedIdentityId, null),
                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.
                // However this is (currently) not the case for MI. We need to convert the 0 to null
                // here in client before sending to the server.
                StorageSizeInGB                  = SqlSkuUtils.ValueIfNonZero(this.StorageSizeInGB),
                SubnetId                         = this.SubnetId,
                VCores                           = this.VCore,
                Sku                              = Sku,
                Collation                        = this.Collation,
                PublicDataEndpointEnabled        = this.PublicDataEndpointEnabled,
                ProxyOverride                    = this.ProxyOverride,
                TimezoneId                       = this.TimezoneId,
                DnsZonePartner                   = this.DnsZonePartner,
                InstancePoolName                 = this.InstancePoolName,
                MinimalTlsVersion                = this.MinimalTlsVersion,
                RequestedBackupStorageRedundancy = this.BackupStorageRedundancy,
                MaintenanceConfigurationId       = this.MaintenanceConfigurationId,
                PrimaryUserAssignedIdentityId    = this.PrimaryUserAssignedIdentityId,
                KeyId                            = this.KeyId,
                Administrators                   = new Management.Sql.Models.ManagedInstanceExternalAdministrator()
                {
                    AzureADOnlyAuthentication = (this.EnableActiveDirectoryOnlyAuthentication.IsPresent) ? (bool?)true : null,
                    Login = this.ExternalAdminName,
                    Sid   = this.ExternalAdminSID
                },
                ZoneRedundant    = this.ZoneRedundant.IsPresent ? this.ZoneRedundant.ToBool() : (bool?)null,
                ServicePrincipal = ResourceServicePrincipalHelper.GetServicePrincipalObjectFromType(this.ServicePrincipalType ?? null)
            });;
            return(newEntity);
        }
Esempio n. 5
0
        /// <summary>
        /// Constructs the model to send to the update API
        /// </summary>
        /// <param name="model">The result of the get operation</param>
        /// <returns>The model to send to the update</returns>
        protected override IEnumerable <AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <AzureSqlManagedInstanceModel> model)
        {
            AzureSqlManagedInstanceModel existingInstance = ModelAdapter.GetManagedInstance(this.ResourceGroupName, this.Name, "administrators/activedirectory");

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            // Get current edition and family
            string currentEdition           = existingInstance.Sku.Tier;
            string currentComputeGeneration = existingInstance.Sku.Family;

            // If either edition or compute generation are set, get the new sku
            if (this.Edition != null || this.ComputeGeneration != null)
            {
                string editionShort = AzureSqlManagedInstanceAdapter.GetInstanceSkuPrefix(!string.IsNullOrWhiteSpace(Edition) ? this.Edition : currentEdition);
                Sku.Name   = editionShort + "_" + (!string.IsNullOrWhiteSpace(this.ComputeGeneration) ? this.ComputeGeneration : currentComputeGeneration);
                Sku.Tier   = !string.IsNullOrWhiteSpace(this.Edition) ? this.Edition : null;
                Sku.Family = !string.IsNullOrWhiteSpace(this.ComputeGeneration) ? this.ComputeGeneration : currentComputeGeneration;
            }
            else
            {
                Sku = existingInstance.Sku;
            }

            // Construct a new entity so we only send the relevant data to the Managed instance
            List <AzureSqlManagedInstanceModel> updateData = new List <AzureSqlManagedInstanceModel>();

            updateData.Add(model.FirstOrDefault());
            updateData[0].ResourceGroupName        = this.ResourceGroupName;
            updateData[0].ManagedInstanceName      = this.Name;
            updateData[0].FullyQualifiedDomainName = this.Name;
            updateData[0].Location = model.FirstOrDefault().Location;
            updateData[0].Sku      = Sku;
            updateData[0].AdministratorPassword = this.AdministratorPassword;
            updateData[0].LicenseType           = this.LicenseType ?? updateData[0].LicenseType;
            updateData[0].StorageSizeInGB       = this.StorageSizeInGB ?? model.FirstOrDefault().StorageSizeInGB;
            updateData[0].VCores = this.VCore ?? updateData[0].VCores;
            updateData[0].PublicDataEndpointEnabled = this.PublicDataEndpointEnabled ?? updateData[0].PublicDataEndpointEnabled;
            updateData[0].ProxyOverride             = this.ProxyOverride ?? this.ProxyOverride;
            updateData[0].Tags                             = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);
            updateData[0].Identity                         = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent, this.IdentityType ?? null, UserAssignedIdentityId, model.FirstOrDefault().Identity);
            updateData[0].InstancePoolName                 = this.InstancePoolName ?? updateData[0].InstancePoolName;
            updateData[0].MinimalTlsVersion                = this.MinimalTlsVersion ?? updateData[0].MinimalTlsVersion;
            updateData[0].MaintenanceConfigurationId       = this.MaintenanceConfigurationId ?? updateData[0].MaintenanceConfigurationId;
            updateData[0].AdministratorLogin               = model.FirstOrDefault().AdministratorLogin;
            updateData[0].PrimaryUserAssignedIdentityId    = this.PrimaryUserAssignedIdentityId ?? model.FirstOrDefault().PrimaryUserAssignedIdentityId;
            updateData[0].KeyId                            = this.KeyId ?? updateData[0].KeyId;
            updateData[0].SubnetId                         = this.SubnetId ?? model.FirstOrDefault().SubnetId;
            updateData[0].ZoneRedundant                    = this.ZoneRedundant.IsPresent ? this.ZoneRedundant.ToBool() : (bool?)null;
            updateData[0].RequestedBackupStorageRedundancy = this.BackupStorageRedundancy ?? updateData[0].CurrentBackupStorageRedundancy;
            updateData[0].ServicePrincipal                 = ResourceServicePrincipalHelper.GetServicePrincipalObjectFromType(this.ServicePrincipalType ?? null);
            return(updateData);
        }
Esempio n. 6
0
        public Guid?AssignServerIdentity(string resourceGroupName, string serverName)
        {
            var server = GetCurrentSqlClient().Servers.Get(resourceGroupName, serverName);

            if (server.Identity == null ||
                server.Identity.Type != ResourceIdentityType.SystemAssigned.ToString())
            {
                server.Identity = ResourceIdentityHelper.GetIdentityObjectFromType(true);
                server          = GetCurrentSqlClient().Servers.CreateOrUpdate(resourceGroupName, serverName, server);
            }

            return(server.Identity.PrincipalId);
        }
Esempio n. 7
0
        /// <summary>
        /// Constructs the model to send to the update API
        /// </summary>
        /// <param name="model">The result of the get operation</param>
        /// <returns>The model to send to the update</returns>
        protected override IEnumerable <AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <AzureSqlManagedInstanceModel> model)
        {
            AzureSqlManagedInstanceModel existingInstance = ModelAdapter.GetManagedInstance(this.ResourceGroupName, this.Name);

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            // Get current edition and family
            string currentEdition           = existingInstance.Sku.Tier;
            string currentComputeGeneration = existingInstance.Sku.Family;

            // If either edition or compute generation are set, get the new sku
            if (this.Edition != null || this.ComputeGeneration != null)
            {
                string editionShort = AzureSqlManagedInstanceAdapter.GetInstanceSkuPrefix(!string.IsNullOrWhiteSpace(Edition) ? this.Edition : currentEdition);
                Sku.Name   = editionShort + "_" + (!string.IsNullOrWhiteSpace(this.ComputeGeneration) ? this.ComputeGeneration : currentComputeGeneration);
                Sku.Tier   = !string.IsNullOrWhiteSpace(this.Edition) ? this.Edition : null;
                Sku.Family = !string.IsNullOrWhiteSpace(this.ComputeGeneration) ? this.ComputeGeneration : currentComputeGeneration;
            }
            else
            {
                Sku = existingInstance.Sku;
            }

            // Construct a new entity so we only send the relevant data to the Managed instance
            List <AzureSqlManagedInstanceModel> updateData = new List <AzureSqlManagedInstanceModel>();

            updateData.Add(new AzureSqlManagedInstanceModel()
            {
                ResourceGroupName        = this.ResourceGroupName,
                ManagedInstanceName      = this.Name,
                FullyQualifiedDomainName = this.Name,
                Location = model.FirstOrDefault().Location,
                Sku      = Sku,
                AdministratorPassword = this.AdministratorPassword,
                LicenseType           = this.LicenseType,
                StorageSizeInGB       = this.StorageSizeInGB ?? model.FirstOrDefault().StorageSizeInGB,
                VCores = this.VCore,
                PublicDataEndpointEnabled = this.PublicDataEndpointEnabled,
                ProxyOverride             = this.ProxyOverride,
                Tags                          = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity                      = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent, this.IdentityType ?? null, UserAssignedIdentityId, model.FirstOrDefault().Identity),
                InstancePoolName              = this.InstancePoolName,
                MinimalTlsVersion             = this.MinimalTlsVersion,
                MaintenanceConfigurationId    = this.MaintenanceConfigurationId,
                AdministratorLogin            = model.FirstOrDefault().AdministratorLogin,
                PrimaryUserAssignedIdentityId = this.PrimaryUserAssignedIdentityId ?? model.FirstOrDefault().PrimaryUserAssignedIdentityId,
                KeyId                         = this.KeyId
            });
            return(updateData);
        }
Esempio n. 8
0
        /// <summary>
        /// Constructs the model to send to the update API
        /// </summary>
        /// <param name="model">The result of the get operation</param>
        /// <returns>The model to send to the update</returns>
        protected override IEnumerable <Model.AzureSqlServerModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlServerModel> model)
        {
            // Construct a new entity so we only send the relevant data to the server
            List <Model.AzureSqlServerModel> updateData = new List <Model.AzureSqlServerModel>();

            updateData.Add(new Model.AzureSqlServerModel()
            {
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                SqlAdministratorPassword = this.SqlAdministratorPassword,
                Tags          = TagsConversionHelper.ReadOrFetchTags(this, model.FirstOrDefault().Tags),
                ServerVersion = this.ServerVersion,
                Location      = model.FirstOrDefault().Location,
                Identity      = model.FirstOrDefault().Identity ?? ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
            });
            return(updateData);
        }
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the server doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlServerModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlServerModel> model)
        {
            List <Model.AzureSqlServerModel> newEntity = new List <Model.AzureSqlServerModel>();

            newEntity.Add(new Model.AzureSqlServerModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                ServerVersion            = this.ServerVersion,
                SqlAdministratorPassword = this.SqlAdministratorCredentials.Password,
                SqlAdministratorLogin    = this.SqlAdministratorCredentials.UserName,
                Tags     = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                Identity = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
            });
            return(newEntity);
        }
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlManagedInstanceModel> model)
        {
            List <Model.AzureSqlManagedInstanceModel> newEntity = new List <Model.AzureSqlManagedInstanceModel>();

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (string.Equals(this.ParameterSetName, NewBySkuNameParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                Sku.Name = SkuName;
            }
            else if (string.Equals(this.ParameterSetName, NewByEditionAndComputeGenerationParameterSet, System.StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(this.ParameterSetName, NewByInstancePoolParentObjectParameterSet, System.StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(this.ParameterSetName, NewByInstancePoolResourceIdParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                string editionShort = AzureSqlManagedInstanceAdapter.GetInstanceSkuPrefix(Edition);
                Sku.Name = editionShort + "_" + ComputeGeneration;
            }

            newEntity.Add(new AzureSqlManagedInstanceModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                FullyQualifiedDomainName = this.Name,
                AdministratorLogin       = this.AdministratorCredential.UserName,
                AdministratorPassword    = this.AdministratorCredential.Password,
                Tags        = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity    = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
                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.
                // However this is (currently) not the case for MI. We need to convert the 0 to null
                // here in client before sending to the server.
                StorageSizeInGB           = SqlSkuUtils.ValueIfNonZero(this.StorageSizeInGB),
                SubnetId                  = this.SubnetId,
                VCores                    = this.VCore,
                Sku                       = Sku,
                Collation                 = this.Collation,
                PublicDataEndpointEnabled = this.PublicDataEndpointEnabled,
                ProxyOverride             = this.ProxyOverride,
                TimezoneId                = this.TimezoneId,
                DnsZonePartner            = this.DnsZonePartner,
                InstancePoolName          = this.InstancePoolName
            });
            return(newEntity);
        }
Esempio n. 11
0
        /// <summary>
        /// Constructs the model to send to the update API
        /// </summary>
        /// <param name="model">The result of the get operation</param>
        /// <returns>The model to send to the update</returns>
        protected override IEnumerable <AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <AzureSqlManagedInstanceModel> model)
        {
            AzureSqlManagedInstanceModel existingInstance = ModelAdapter.GetManagedInstance(this.ResourceGroupName, this.Name);

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (Edition != null)
            {
                string computeGeneration = existingInstance.Sku.Name.Contains(Constants.ComputeGenerationGen4) ? Constants.ComputeGenerationGen4 : Constants.ComputeGenerationGen5;
                string editionShort      = AzureSqlManagedInstanceAdapter.GetInstanceSkuPrefix(Edition);
                Sku.Name = editionShort + "_" + computeGeneration;
                Sku.Tier = Edition;
            }
            else
            {
                Sku = null;
            }

            // Construct a new entity so we only send the relevant data to the Managed instance
            List <AzureSqlManagedInstanceModel> updateData = new List <AzureSqlManagedInstanceModel>();

            updateData.Add(new AzureSqlManagedInstanceModel()
            {
                ResourceGroupName        = this.ResourceGroupName,
                ManagedInstanceName      = this.Name,
                FullyQualifiedDomainName = this.Name,
                Location = model.FirstOrDefault().Location,
                Sku      = Sku,
                AdministratorPassword = this.AdministratorPassword,
                LicenseType           = this.LicenseType,
                StorageSizeInGB       = this.StorageSizeInGB ?? model.FirstOrDefault().StorageSizeInGB,
                VCores = this.VCore,
                PublicDataEndpointEnabled = this.PublicDataEndpointEnabled,
                ProxyOverride             = this.ProxyOverride,
                Tags             = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity         = model.FirstOrDefault().Identity ?? ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
                InstancePoolName = this.InstancePoolName
            });
            return(updateData);
        }
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlManagedInstanceModel> model)
        {
            List <Model.AzureSqlManagedInstanceModel> newEntity = new List <Model.AzureSqlManagedInstanceModel>();

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (string.Equals(this.ParameterSetName, NewBySkuNameParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                Sku.Name = SkuName;
            }
            else if (string.Equals(this.ParameterSetName, NewByEditionAndComputeGenerationParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                string editionShort = AzureSqlManagedInstanceAdapter.GetInstanceSkuPrefix(Edition);
                Sku.Name = editionShort + "_" + ComputeGeneration;
            }

            newEntity.Add(new Model.AzureSqlManagedInstanceModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                FullyQualifiedDomainName = this.Name,
                AdministratorLogin       = this.AdministratorCredential.UserName,
                AdministratorPassword    = this.AdministratorCredential.Password,
                Tags                      = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity                  = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
                LicenseType               = this.LicenseType,
                StorageSizeInGB           = this.StorageSizeInGB,
                SubnetId                  = this.SubnetId,
                VCores                    = this.VCore,
                Sku                       = Sku,
                Collation                 = this.Collation,
                PublicDataEndpointEnabled = this.PublicDataEndpointEnabled,
                ProxyOverride             = this.ProxyOverride,
                TimezoneId                = this.TimezoneId,
                DnsZonePartner            = this.DnsZonePartner
            });
            return(newEntity);
        }
Esempio n. 13
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the server doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlServerModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlServerModel> model)
        {
            if (!Sql.Services.Util.ValidateServerName(this.ServerName))
            {
                throw new PSArgumentException(string.Format(Properties.Resources.ServerNameInvalid, this.ServerName), "ServerName");
            }

            List <Model.AzureSqlServerModel> newEntity = new List <Model.AzureSqlServerModel>();

            newEntity.Add(new Model.AzureSqlServerModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                ServerVersion            = this.ServerVersion,
                SqlAdministratorPassword = this.SqlAdministratorCredentials.Password,
                SqlAdministratorLogin    = this.SqlAdministratorCredentials.UserName,
                Tags                = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                Identity            = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
                MinimalTlsVersion   = this.MinimalTlsVersion,
                PublicNetworkAccess = this.PublicNetworkAccess,
            });
            return(newEntity);
        }