Skip to content

Commit 4b8b0e1

Browse files
committed
Ignore user input for elastic pool's StorageMB and recalculate based on Dtu and coefficient of the edition
1 parent c3a8174 commit 4b8b0e1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/ResourceManager/Sql/Commands.Sql/ServerUpgrade/Cmdlet/StartAzureSqlServerUpgrade.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public class StartAzureSqlServerUpgrade : AzureSqlServerUpgradeCmdletBase<AzureS
5353
HelpMessage = "Determines the collection of recommended elastic pool properties for server upgrade")]
5454
public UpgradeRecommendedElasticPoolProperties[] ElasticPoolCollection { get; set; }
5555

56+
private const int StorageMbPerDtuBasic = 100;
57+
private const int StorageMbPerDtuStandard = 1024;
58+
private const int StorageMbPerDtuPremium = 512;
59+
5660
/// <summary>
5761
/// Check to see if the server already exists in this resource group.
5862
/// </summary>
@@ -82,6 +86,26 @@ public class StartAzureSqlServerUpgrade : AzureSqlServerUpgradeCmdletBase<AzureS
8286
/// <returns>The generated model from user input</returns>
8387
protected override IEnumerable<AzureSqlServerUpgradeStartModel> ApplyUserInputToModel(IEnumerable<AzureSqlServerUpgradeStartModel> models)
8488
{
89+
// Ignore user input and recalculate StorageMb based on Dtu and coefficient of the edition
90+
foreach (var elasticPoolProperties in ElasticPoolCollection)
91+
{
92+
switch (elasticPoolProperties.Edition.ToLower())
93+
{
94+
case "basic":
95+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu*StorageMbPerDtuBasic;
96+
break;
97+
case "standard":
98+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuStandard;
99+
break;
100+
case "premium":
101+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuPremium;
102+
break;
103+
default:
104+
throw new PSArgumentException(string.Format("Edition {0} is invalid", elasticPoolProperties.Edition));
105+
}
106+
107+
}
108+
85109
var newEntity = new List<AzureSqlServerUpgradeStartModel>();
86110
newEntity.Add(new AzureSqlServerUpgradeStartModel
87111
{

0 commit comments

Comments
 (0)