@@ -188,15 +188,6 @@ public class SetAzureSqlManagedInstance : ManagedInstanceCmdletBase
188
188
[ PSArgumentCompleter ( Constants . ComputeGenerationGen5 ) ]
189
189
public string ComputeGeneration { get ; set ; }
190
190
191
- /// <summary>
192
- /// Gets or sets the instance SKU name
193
- /// </summary>
194
- [ Parameter ( Mandatory = false ,
195
- HelpMessage = "The SKU name for the instance e.g. 'GP_Gen5','BC_Gen5'." ) ]
196
- [ ValidateNotNullOrEmpty ]
197
- [ PSArgumentCompleter ( Constants . GeneralPurposeGen5 , Constants . BusinessCriticalGen5 ) ]
198
- public string SkuName { get ; set ; }
199
-
200
191
/// <summary>
201
192
/// Get the instance to update
202
193
/// </summary>
@@ -219,47 +210,18 @@ protected bool ShouldConfirmHardwareFamilyChange()
219
210
// Get current hardware family
220
211
string currentHardwareFamily = existingInstance . Sku . Family ;
221
212
222
- // Get requested hardware family
223
- string requestedHardwareFamily = ! string . IsNullOrWhiteSpace ( this . SkuName ) ? AzureSqlManagedInstanceAdapter . GetHardwareGenerationFromSkuName ( this . SkuName ) : this . ComputeGeneration ;
224
-
225
- bool isHardwareFamilyChanged = ! string . IsNullOrWhiteSpace ( requestedHardwareFamily ) && ! currentHardwareFamily . Equals ( requestedHardwareFamily , StringComparison . InvariantCultureIgnoreCase ) ;
213
+ // Check whether the hardware family was changed
214
+ bool isHardwareFamilyChanged = ! currentHardwareFamily . Equals ( this . ComputeGeneration , StringComparison . InvariantCultureIgnoreCase ) ;
226
215
227
- // Check whether hardware family is being changed to a deprecated hardware family
228
- if ( isHardwareFamilyChanged && requestedHardwareFamily . Equals ( Constants . ComputeGenerationGen5 , StringComparison . InvariantCultureIgnoreCase ) )
216
+ // Check whether hardware family is being changed to a newer hardware family
217
+ if ( isHardwareFamilyChanged && currentHardwareFamily . Equals ( Constants . ComputeGenerationGen4 , StringComparison . InvariantCultureIgnoreCase ) )
229
218
{
230
219
shouldConfirmHardwareFamilyChange = true ;
231
220
}
232
221
233
222
return shouldConfirmHardwareFamilyChange ;
234
223
}
235
224
236
- /// <summary>
237
- /// Get edition from SKU name.
238
- /// </summary>
239
- /// <returns>The model to send to the update</returns>
240
- protected string GetEditionFromSkuName ( string skuName )
241
- {
242
- if ( string . IsNullOrWhiteSpace ( skuName ) )
243
- {
244
- return null ;
245
- }
246
-
247
- string edition = null ;
248
-
249
- if ( skuName . Equals ( Constants . GeneralPurposeGen4 , StringComparison . InvariantCultureIgnoreCase )
250
- || skuName . Equals ( Constants . GeneralPurposeGen5 , StringComparison . InvariantCultureIgnoreCase ) )
251
- {
252
- edition = Constants . GeneralPurposeEdition ;
253
- }
254
- else if ( skuName . Equals ( Constants . BusinessCriticalGen4 , StringComparison . InvariantCultureIgnoreCase )
255
- || skuName . Equals ( Constants . BusinessCriticalGen5 , StringComparison . InvariantCultureIgnoreCase ) )
256
- {
257
- edition = Constants . BusinessCriticalEdition ;
258
- }
259
-
260
- return edition ;
261
- }
262
-
263
225
/// <summary>
264
226
/// Constructs the model to send to the update API
265
227
/// </summary>
@@ -270,26 +232,21 @@ protected override IEnumerable<AzureSqlManagedInstanceModel> ApplyUserInputToMod
270
232
AzureSqlManagedInstanceModel existingInstance = ModelAdapter . GetManagedInstance ( this . ResourceGroupName , this . Name ) ;
271
233
Management . Internal . Resources . Models . Sku Sku = new Management . Internal . Resources . Models . Sku ( ) ;
272
234
273
- // Get current edition
235
+ // Get current edition and family
274
236
string currentEdition = existingInstance . Sku . Tier ;
237
+ string currentComputeGeneration = existingInstance . Sku . Family ;
275
238
276
- // Get current hardware family
277
- string currentComputeGeneration = existingInstance . Sku . Name . Contains ( Constants . ComputeGenerationGen4 ) ? Constants . ComputeGenerationGen4 : Constants . ComputeGenerationGen5 ;
278
-
279
- if ( SkuName != null )
280
- {
281
- Sku . Name = SkuName ;
282
- }
283
- else if ( Edition != null || ComputeGeneration != null )
239
+ // If either edition or compute generation are set, get the new sku
240
+ if ( this . Edition != null || this . ComputeGeneration != null )
284
241
{
285
- string editionShort = AzureSqlManagedInstanceAdapter . GetInstanceSkuPrefix ( ! string . IsNullOrWhiteSpace ( Edition ) ? Edition : currentEdition ) ;
286
- Sku . Name = editionShort + "_" + ( ! string . IsNullOrWhiteSpace ( ComputeGeneration ) ? ComputeGeneration : currentComputeGeneration ) ;
287
- Sku . Tier = ! string . IsNullOrWhiteSpace ( Edition ) ? Edition : null ;
288
- Sku . Family = ! string . IsNullOrWhiteSpace ( ComputeGeneration ) ? ComputeGeneration : currentComputeGeneration ;
242
+ string editionShort = AzureSqlManagedInstanceAdapter . GetInstanceSkuPrefix ( ! string . IsNullOrWhiteSpace ( Edition ) ? this . Edition : currentEdition ) ;
243
+ Sku . Name = editionShort + "_" + ( ! string . IsNullOrWhiteSpace ( this . ComputeGeneration ) ? this . ComputeGeneration : currentComputeGeneration ) ;
244
+ Sku . Tier = ! string . IsNullOrWhiteSpace ( this . Edition ) ? this . Edition : null ;
245
+ Sku . Family = ! string . IsNullOrWhiteSpace ( this . ComputeGeneration ) ? this . ComputeGeneration : currentComputeGeneration ;
289
246
}
290
247
else
291
248
{
292
- Sku = null ;
249
+ Sku = existingInstance . Sku ;
293
250
}
294
251
295
252
// Construct a new entity so we only send the relevant data to the Managed instance
@@ -329,6 +286,7 @@ protected override IEnumerable<AzureSqlManagedInstanceModel> PersistChanges(IEnu
329
286
/// </summary>
330
287
public override void ExecuteCmdlet ( )
331
288
{
289
+ System . Diagnostics . Debugger . Launch ( ) ;
332
290
if ( ! Force . IsPresent && ! ShouldContinue (
333
291
string . Format ( CultureInfo . InvariantCulture , Properties . Resources . SetAzureSqlInstanceDescription , this . Name ) ,
334
292
string . Format ( CultureInfo . InvariantCulture , Properties . Resources . SetAzureSqlInstanceWarning , this . Name ) ) )
@@ -350,14 +308,14 @@ public override void ExecuteCmdlet()
350
308
}
351
309
352
310
// Validate requested hardware family
353
- if ( ! string . IsNullOrWhiteSpace ( this . SkuName ) || ! string . IsNullOrWhiteSpace ( this . ComputeGeneration ) )
311
+ if ( ! string . IsNullOrWhiteSpace ( this . ComputeGeneration ) )
354
312
{
355
313
// Hardware family is being changed to a newer hardware family and it is not possible to scale back - Give confirmation message
356
314
if ( this . ShouldConfirmHardwareFamilyChange ( ) )
357
315
{
358
316
if ( ! Force . IsPresent && ! ShouldContinue (
359
317
string . Format ( CultureInfo . InvariantCulture , Properties . Resources . DoYouWantToProceed , this . Name ) ,
360
- string . Format ( CultureInfo . InvariantCulture , Properties . Resources . ChangingHardwareFamilyIsIrreversable , this . Name ) ) )
318
+ string . Format ( CultureInfo . InvariantCulture , string . Format ( Properties . Resources . ChangingHardwareFamilyIsIrreversable , this . ComputeGeneration ) , this . Name ) ) )
361
319
{
362
320
return ;
363
321
}
0 commit comments