Skip to content

Commit a2d4b68

Browse files
committed
Merge pull request #739 from hungmai-msft/fix-storagemb
Fix StorageMb parameter
2 parents 2e70e4e + 2806d82 commit a2d4b68

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 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,29 @@ 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+
if (ElasticPoolCollection != null)
90+
{
91+
// Ignore user input and recalculate StorageMb based on Dtu and coefficient of the edition
92+
foreach (var elasticPoolProperties in ElasticPoolCollection)
93+
{
94+
switch (elasticPoolProperties.Edition.ToLower())
95+
{
96+
case "basic":
97+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuBasic;
98+
break;
99+
case "standard":
100+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuStandard;
101+
break;
102+
case "premium":
103+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuPremium;
104+
break;
105+
default:
106+
throw new PSArgumentException(string.Format("Edition {0} is invalid", elasticPoolProperties.Edition));
107+
}
108+
109+
}
110+
}
111+
85112
var newEntity = new List<AzureSqlServerUpgradeStartModel>();
86113
newEntity.Add(new AzureSqlServerUpgradeStartModel
87114
{

0 commit comments

Comments
 (0)