/// <summary> /// Creates UpgradeDatabaseHint from database object by using same edition and SLO from upgrade hint. /// </summary> /// <param name="database">Database object</param> /// <returns>Returns UpgradeDatabaseHint</returns> private RecommendedDatabaseProperties CreateUpgradeDatabaseHint(Management.Sql.LegacySdk.Models.Database database) { return(new RecommendedDatabaseProperties() { Name = database.Name, TargetEdition = SloToEdition(database.Properties.UpgradeHint.TargetServiceLevelObjective), TargetServiceLevelObjective = database.Properties.UpgradeHint.TargetServiceLevelObjective }); }
/// <summary> /// Construct AzureSqlDatabaseModel from Management.Sql.LegacySdk.Models.Database object /// </summary> /// <param name="resourceGroup">Resource group</param> /// <param name="serverName">Server name</param> /// <param name="database">Database object</param> public AzureSqlDatabaseModel(string resourceGroup, string serverName, Management.Sql.LegacySdk.Models.Database database) { Guid id = Guid.Empty; ResourceGroupName = resourceGroup; ServerName = serverName; CollationName = database.Properties.Collation; CreationDate = database.Properties.CreationDate; CurrentServiceObjectiveName = database.Properties.ServiceObjective; MaxSizeBytes = database.Properties.MaxSizeBytes; DatabaseName = database.Name; Status = database.Properties.Status; Tags = TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(database.Tags), false); ElasticPoolName = database.Properties.ElasticPoolName; Location = database.Location; ResourceId = database.Id; CreateMode = database.Properties.CreateMode; EarliestRestoreDate = database.Properties.EarliestRestoreDate; Guid.TryParse(database.Properties.CurrentServiceObjectiveId, out id); CurrentServiceObjectiveId = id; Guid.TryParse(database.Properties.DatabaseId, out id); DatabaseId = id; Edition = database.Properties.Edition; Guid.TryParse(database.Properties.RequestedServiceObjectiveId, out id); RequestedServiceObjectiveId = id; DatabaseReadScale readScale; if (Enum.TryParse <DatabaseReadScale>(database.Properties.ReadScale, true, out readScale)) { ReadScale = readScale; } ZoneRedundant = false; AutoPauseDelayInMinutes = null; MinimumCapacity = null; ReadReplicaCount = null; HighAvailabilityReplicaCount = null; CurrentBackupStorageRedundancy = null; RequestedBackupStorageRedundancy = null; SecondaryType = null; MaintenanceConfigurationId = null; EnableLedger = false; }
/// <summary> /// Construct AzureSqlDatabaseModel from Management.Sql.LegacySdk.Models.Database object /// </summary> /// <param name="resourceGroup">Resource group</param> /// <param name="serverName">Server name</param> /// <param name="database">Database object</param> public AzureSqlDatabaseModel(string resourceGroup, string serverName, Management.Sql.LegacySdk.Models.Database database) { Guid id = Guid.Empty; DatabaseEdition edition = DatabaseEdition.None; DatabaseReadScale readScale = DatabaseReadScale.Enabled; ResourceGroupName = resourceGroup; ServerName = serverName; CollationName = database.Properties.Collation; CreationDate = database.Properties.CreationDate; CurrentServiceObjectiveName = database.Properties.ServiceObjective; MaxSizeBytes = database.Properties.MaxSizeBytes; DatabaseName = database.Name; Status = database.Properties.Status; Tags = TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(database.Tags), false); ElasticPoolName = database.Properties.ElasticPoolName; Location = database.Location; ResourceId = database.Id; CreateMode = database.Properties.CreateMode; EarliestRestoreDate = database.Properties.EarliestRestoreDate; Guid.TryParse(database.Properties.CurrentServiceObjectiveId, out id); CurrentServiceObjectiveId = id; Guid.TryParse(database.Properties.DatabaseId, out id); DatabaseId = id; Enum.TryParse <DatabaseEdition>(database.Properties.Edition, true, out edition); Edition = edition; Guid.TryParse(database.Properties.RequestedServiceObjectiveId, out id); RequestedServiceObjectiveId = id; Enum.TryParse <DatabaseReadScale>(database.Properties.ReadScale, true, out readScale); ReadScale = readScale; ZoneRedundant = false; }
/// <summary> /// Converts the response from the service to a powershell database object /// </summary> /// <param name="resourceGroup">The resource group the server is in</param> /// <param name="serverName">The name of the Azure Sql Database Server</param> /// <param name="database">The service response</param> /// <returns>The converted model</returns> public static AzureSqlDatabaseModelExpanded CreateExpandedDatabaseModelFromResponse(string resourceGroup, string serverName, Management.Sql.LegacySdk.Models.Database database) { return(new AzureSqlDatabaseModelExpanded(resourceGroup, serverName, database)); }
/// <summary> /// Construct AzureSqlDatabaseModelExpanded from Management.Sql.LegacySdk.Models.Database object /// </summary> /// <param name="resourceGroup">Resource group</param> /// <param name="serverName">Server name</param> /// <param name="database">Database object</param> public AzureSqlDatabaseModelExpanded(string resourceGroup, string serverName, Management.Sql.LegacySdk.Models.Database database) : base(resourceGroup, serverName, database) { if (database.Properties.ServiceTierAdvisors != null && database.Properties.ServiceTierAdvisors.Count > 0) { ServiceTierAdvisor = database.Properties.ServiceTierAdvisors[0].Properties; } }