示例#1
0
        /// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureSqlDatabaseCopyModel> ApplyUserInputToModel(IEnumerable <AzureSqlDatabaseCopyModel> model)
        {
            string copyResourceGroup = string.IsNullOrWhiteSpace(CopyResourceGroupName) ? ResourceGroupName : CopyResourceGroupName;
            string copyServer        = string.IsNullOrWhiteSpace(CopyServerName) ? ServerName : CopyServerName;

            string location     = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName);
            string copyLocation = copyServer.Equals(ServerName) ? location : ModelAdapter.GetServerLocation(copyResourceGroup, copyServer);

            Database.Model.AzureSqlDatabaseModel   sourceDb  = ModelAdapter.GetDatabase(ResourceGroupName, ServerName, DatabaseName);
            List <Model.AzureSqlDatabaseCopyModel> newEntity = new List <AzureSqlDatabaseCopyModel>();

            AzureSqlDatabaseCopyModel copyModel = new AzureSqlDatabaseCopyModel()
            {
                Location              = location,
                ResourceGroupName     = ResourceGroupName,
                ServerName            = ServerName,
                DatabaseName          = DatabaseName,
                CopyResourceGroupName = copyResourceGroup,
                CopyServerName        = copyServer,
                CopyDatabaseName      = CopyDatabaseName,
                CopyLocation          = copyLocation,
                ServiceObjectiveName  = ServiceObjectiveName,
                ElasticPoolName       = ElasticPoolName,
                Tags        = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                LicenseType = LicenseType, // note: default license type is LicenseIncluded
                RequestedBackupStorageRedundancy = BackupStorageRedundancy,
                ZoneRedundant = this.IsParameterBound(p => p.ZoneRedundant) ? ZoneRedundant.ToBool() : (bool?)null,
            };

            if (ParameterSetName == DtuDatabaseParameterSet)
            {
                if (!string.IsNullOrWhiteSpace(ServiceObjectiveName))
                {
                    copyModel.SkuName = ServiceObjectiveName;
                }
                else if (string.IsNullOrWhiteSpace(ElasticPoolName))
                {
                    copyModel.SkuName  = sourceDb.CurrentServiceObjectiveName;
                    copyModel.Edition  = sourceDb.Edition;
                    copyModel.Capacity = sourceDb.Capacity;
                    copyModel.Family   = sourceDb.Family;
                }
            }
            else
            {
                copyModel.SkuName  = AzureSqlDatabaseAdapter.GetDatabaseSkuName(sourceDb.Edition);
                copyModel.Edition  = sourceDb.Edition;
                copyModel.Capacity = VCore;
                copyModel.Family   = ComputeGeneration;
            }

            newEntity.Add(copyModel);
            return(newEntity);
        }
        /// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureSqlDatabaseCopyModel> ApplyUserInputToModel(IEnumerable <AzureSqlDatabaseCopyModel> model)
        {
            string copyResourceGroup = string.IsNullOrWhiteSpace(CopyResourceGroupName) ? ResourceGroupName : CopyResourceGroupName;
            string copyServer        = string.IsNullOrWhiteSpace(CopyServerName) ? ServerName : CopyServerName;

            string location     = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName);
            string copyLocation = copyServer.Equals(ServerName) ? location : ModelAdapter.GetServerLocation(copyResourceGroup, copyServer);

            Database.Model.AzureSqlDatabaseModel   sourceDb  = ModelAdapter.GetDatabase(ResourceGroupName, ServerName, DatabaseName);
            List <Model.AzureSqlDatabaseCopyModel> newEntity = new List <AzureSqlDatabaseCopyModel>();

            AzureSqlDatabaseCopyModel copyModel = new AzureSqlDatabaseCopyModel()
            {
                Location              = location,
                ResourceGroupName     = ResourceGroupName,
                ServerName            = ServerName,
                DatabaseName          = DatabaseName,
                CopyResourceGroupName = copyResourceGroup,
                CopyServerName        = copyServer,
                CopyDatabaseName      = CopyDatabaseName,
                CopyLocation          = copyLocation,
                ServiceObjectiveName  = ServiceObjectiveName,
                ElasticPoolName       = ElasticPoolName,
                Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true)
            };

            if (ParameterSetName == DtuDatabaseParameterSet)
            {
                if (!string.IsNullOrWhiteSpace(ServiceObjectiveName))
                {
                    copyModel.SkuName = ServiceObjectiveName;
                }
                else if (string.IsNullOrWhiteSpace(ElasticPoolName))
                {
                    copyModel.SkuName  = sourceDb.CurrentServiceObjectiveName;
                    copyModel.Edition  = sourceDb.Edition;
                    copyModel.Capacity = sourceDb.Capacity;
                    copyModel.Family   = sourceDb.Family;
                }
            }
            else
            {
                copyModel.SkuName  = AzureSqlDatabaseAdapter.GetDatabaseSkuName(sourceDb.Edition);
                copyModel.Edition  = sourceDb.Edition;
                copyModel.Capacity = VCore;
                copyModel.Family   = ComputeGeneration;
            }

            newEntity.Add(copyModel);
            return(newEntity);
        }
示例#3
0
        /// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureReplicationLinkModel> ApplyUserInputToModel(IEnumerable <AzureReplicationLinkModel> model)
        {
            string location = ModelAdapter.GetServerLocation(this.PartnerResourceGroupName, this.PartnerServerName);
            List <Model.AzureReplicationLinkModel> newEntity = new List <AzureReplicationLinkModel>();

            Database.Model.AzureSqlDatabaseModel primaryDb = ModelAdapter.GetDatabase(ResourceGroupName, ServerName, DatabaseName);

            AzureReplicationLinkModel linkModel = new AzureReplicationLinkModel()
            {
                PartnerLocation          = location,
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                DatabaseName             = this.DatabaseName,
                PartnerResourceGroupName = this.PartnerResourceGroupName,
                PartnerServerName        = this.PartnerServerName,
                PartnerDatabaseName      = GetEffectivePartnerDatabaseName(this.DatabaseName, this.PartnerDatabaseName),
                SecondaryElasticPoolName = this.SecondaryElasticPoolName,
                AllowConnections         = this.AllowConnections,
                Tags        = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                LicenseType = LicenseType,
                RequestedBackupStorageRedundancy = this.BackupStorageRedundancy,
                SecondaryType = SecondaryType,
                HighAvailabilityReplicaCount = this.IsParameterBound(p => p.HighAvailabilityReplicaCount) ? HighAvailabilityReplicaCount : (int?)null,
                ZoneRedundant = this.IsParameterBound(p => p.ZoneRedundant) ? ZoneRedundant.ToBool() : (bool?)null,
            };

            if (ParameterSetName == DtuDatabaseParameterSet)
            {
                if (!string.IsNullOrWhiteSpace(SecondaryServiceObjectiveName))
                {
                    linkModel.SkuName = SecondaryServiceObjectiveName;
                }
                else if (string.IsNullOrWhiteSpace(SecondaryElasticPoolName))
                {
                    linkModel.SkuName  = primaryDb.CurrentServiceObjectiveName;
                    linkModel.Edition  = primaryDb.Edition;
                    linkModel.Capacity = primaryDb.Capacity;
                    linkModel.Family   = primaryDb.Family;
                }
            }
            else
            {
                linkModel.SkuName  = AzureSqlDatabaseAdapter.GetDatabaseSkuName(primaryDb.Edition);
                linkModel.Edition  = primaryDb.Edition;
                linkModel.Capacity = SecondaryVCore;
                linkModel.Family   = SecondaryComputeGeneration;
            }

            newEntity.Add(linkModel);
            return(newEntity);
        }
        /// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureReplicationLinkModel> ApplyUserInputToModel(IEnumerable <AzureReplicationLinkModel> model)
        {
            string location = ModelAdapter.GetServerLocation(this.PartnerResourceGroupName, this.PartnerServerName);
            List <Model.AzureReplicationLinkModel> newEntity = new List <AzureReplicationLinkModel>();

            Database.Model.AzureSqlDatabaseModel primaryDb = ModelAdapter.GetDatabase(ResourceGroupName, ServerName, DatabaseName);

            AzureReplicationLinkModel linkModel = new AzureReplicationLinkModel()
            {
                PartnerLocation          = location,
                ResourceGroupName        = this.ResourceGroupName,
                ServerName               = this.ServerName,
                DatabaseName             = this.DatabaseName,
                PartnerResourceGroupName = this.PartnerResourceGroupName,
                PartnerServerName        = this.PartnerServerName,
                PartnerDatabaseName      = string.IsNullOrWhiteSpace(this.PartnerDatabaseName) ? this.DatabaseName : this.PartnerDatabaseName,
                SecondaryElasticPoolName = this.SecondaryElasticPoolName,
                AllowConnections         = this.AllowConnections,
                Tags        = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
                LicenseType = LicenseType
            };

            if (ParameterSetName == DtuDatabaseParameterSet)
            {
                if (!string.IsNullOrWhiteSpace(SecondaryServiceObjectiveName))
                {
                    linkModel.SkuName = SecondaryServiceObjectiveName;
                }
                else if (string.IsNullOrWhiteSpace(SecondaryElasticPoolName))
                {
                    linkModel.SkuName  = primaryDb.CurrentServiceObjectiveName;
                    linkModel.Edition  = primaryDb.Edition;
                    linkModel.Capacity = primaryDb.Capacity;
                    linkModel.Family   = primaryDb.Family;
                }
            }
            else
            {
                linkModel.SkuName  = AzureSqlDatabaseAdapter.GetDatabaseSkuName(primaryDb.Edition);
                linkModel.Edition  = primaryDb.Edition;
                linkModel.Capacity = SecondaryVCore;
                linkModel.Family   = SecondaryComputeGeneration;
            }

            newEntity.Add(linkModel);
            return(newEntity);
        }