@@ -405,41 +405,21 @@ public Variable CreateVariable(Variable variable)
405
405
Resources . VariableAlreadyExists , variable . Name ) ) ;
406
406
}
407
407
408
- if ( variable . Encrypted )
408
+ var createParams = new AutomationManagement . Models . VariableCreateParameters ( )
409
409
{
410
- var createParams = new AutomationManagement . Models . EncryptedVariableCreateParameters ( )
410
+ Name = variable . Name ,
411
+ Properties = new AutomationManagement . Models . VariableCreateProperties ( )
411
412
{
412
- Name = variable . Name ,
413
- Properties = new AutomationManagement . Models . EncryptedVariableCreateProperties ( )
414
- {
415
- Value = PowerShellJsonConverter . Serialize ( variable . Value ) ,
416
- Description = variable . Description
417
- }
418
- } ;
419
-
420
- var sdkCreatedVariable =
421
- this . automationManagementClient . EncryptedVariables . Create ( variable . AutomationAccountName , createParams )
422
- . EncryptedVariable ;
423
-
424
- return new Variable ( sdkCreatedVariable , variable . AutomationAccountName ) ;
425
- }
426
- else
427
- {
428
- var createParams = new AutomationManagement . Models . VariableCreateParameters ( )
429
- {
430
- Name = variable . Name ,
431
- Properties = new AutomationManagement . Models . VariableCreateProperties ( )
432
- {
433
- Value = PowerShellJsonConverter . Serialize ( variable . Value ) ,
434
- Description = variable . Description
435
- }
436
- } ;
413
+ Value = PowerShellJsonConverter . Serialize ( variable . Value ) ,
414
+ Description = variable . Description ,
415
+ IsEncrypted = variable . Encrypted
416
+ }
417
+ } ;
437
418
438
- var sdkCreatedVariable =
439
- this . automationManagementClient . Variables . Create ( variable . AutomationAccountName , createParams ) . Variable ;
419
+ var sdkCreatedVariable =
420
+ this . automationManagementClient . Variables . Create ( variable . AutomationAccountName , createParams ) . Variable ;
440
421
441
- return new Variable ( sdkCreatedVariable , variable . AutomationAccountName ) ;
442
- }
422
+ return new Variable ( sdkCreatedVariable , variable . AutomationAccountName ) ;
443
423
}
444
424
445
425
public void DeleteVariable ( string automationAccountName , string variableName )
@@ -448,14 +428,7 @@ public void DeleteVariable(string automationAccountName, string variableName)
448
428
{
449
429
var existingVarible = this . GetVariable ( automationAccountName , variableName ) ;
450
430
451
- if ( existingVarible . Encrypted )
452
- {
453
- this . automationManagementClient . EncryptedVariables . Delete ( automationAccountName , variableName ) ;
454
- }
455
- else
456
- {
457
- this . automationManagementClient . Variables . Delete ( automationAccountName , variableName ) ;
458
- }
431
+ this . automationManagementClient . Variables . Delete ( automationAccountName , variableName ) ;
459
432
}
460
433
catch ( CloudException cloudException )
461
434
{
@@ -479,75 +452,33 @@ public Variable UpdateVariable(Variable variable, VariableUpdateFields updateFie
479
452
string . Format ( CultureInfo . CurrentCulture , Resources . VariableEncryptionCannotBeChanged , variable . Name , existingVariable . Encrypted ) ) ;
480
453
}
481
454
482
- if ( variable . Encrypted )
455
+ var updateParams = new AutomationManagement . Models . VariableUpdateParameters ( )
483
456
{
484
- var updateParams = new AutomationManagement . Models . EncryptedVariableUpdateParameters ( )
485
- {
486
- Name = variable . Name
487
- } ;
457
+ Name = variable . Name ,
458
+ } ;
488
459
489
- if ( updateFields == VariableUpdateFields . OnlyDescription )
490
- {
491
- updateParams . Properties = new AutomationManagement . Models . EncryptedVariableUpdateProperties ( )
492
- {
493
- Description = variable . Description
494
- } ;
495
- }
496
- else
460
+ if ( updateFields == VariableUpdateFields . OnlyDescription )
461
+ {
462
+ updateParams . Properties = new AutomationManagement . Models . VariableUpdateProperties ( )
497
463
{
498
- updateParams . Properties = new AutomationManagement . Models . EncryptedVariableUpdateProperties ( )
499
- {
500
- Value = PowerShellJsonConverter . Serialize ( variable . Value )
501
- } ;
502
- }
503
-
504
- this . automationManagementClient . EncryptedVariables . Update ( variable . AutomationAccountName , updateParams ) ;
464
+ Description = variable . Description
465
+ } ;
505
466
}
506
467
else
507
468
{
508
- var updateParams = new AutomationManagement . Models . VariableUpdateParameters ( )
469
+ updateParams . Properties = new AutomationManagement . Models . VariableUpdateProperties ( )
509
470
{
510
- Name = variable . Name ,
471
+ Value = PowerShellJsonConverter . Serialize ( variable . Value )
511
472
} ;
512
-
513
- if ( updateFields == VariableUpdateFields . OnlyDescription )
514
- {
515
- updateParams . Properties = new AutomationManagement . Models . VariableUpdateProperties ( )
516
- {
517
- Description = variable . Description
518
- } ;
519
- }
520
- else
521
- {
522
- updateParams . Properties = new AutomationManagement . Models . VariableUpdateProperties ( )
523
- {
524
- Value = PowerShellJsonConverter . Serialize ( variable . Value )
525
- } ;
526
- }
527
-
528
- this . automationManagementClient . Variables . Update ( variable . AutomationAccountName , updateParams ) ;
529
473
}
530
474
475
+ this . automationManagementClient . Variables . Update ( variable . AutomationAccountName , updateParams ) ;
476
+
531
477
return this . GetVariable ( variable . AutomationAccountName , variable . Name ) ;
532
478
}
533
479
534
480
public Variable GetVariable ( string automationAccountName , string name )
535
481
{
536
- try
537
- {
538
- var sdkEncryptedVariable = this . automationManagementClient . EncryptedVariables . Get (
539
- automationAccountName , name ) . EncryptedVariable ;
540
-
541
- if ( sdkEncryptedVariable != null )
542
- {
543
- return new Variable ( sdkEncryptedVariable , automationAccountName ) ;
544
- }
545
- }
546
- catch ( CloudException )
547
- {
548
- // do nothing
549
- }
550
-
551
482
try
552
483
{
553
484
var sdkVarible = this . automationManagementClient . Variables . Get ( automationAccountName , name ) . Variable ;
@@ -556,14 +487,15 @@ public Variable GetVariable(string automationAccountName, string name)
556
487
{
557
488
return new Variable ( sdkVarible , automationAccountName ) ;
558
489
}
490
+
491
+ throw new ResourceNotFoundException ( typeof ( Variable ) ,
492
+ string . Format ( CultureInfo . CurrentCulture , Resources . VariableNotFound , name ) ) ;
559
493
}
560
494
catch ( CloudException )
561
495
{
562
- // do nothing
496
+ throw new ResourceNotFoundException ( typeof ( Variable ) ,
497
+ string . Format ( CultureInfo . CurrentCulture , Resources . VariableNotFound , name ) ) ;
563
498
}
564
-
565
- throw new ResourceNotFoundException ( typeof ( Variable ) ,
566
- string . Format ( CultureInfo . CurrentCulture , Resources . VariableNotFound , name ) ) ;
567
499
}
568
500
569
501
public IEnumerable < Variable > ListVariables ( string automationAccountName )
@@ -577,20 +509,7 @@ public IEnumerable<Variable> ListVariables(string automationAccountName)
577
509
response , response . Variables ) ;
578
510
} ) ;
579
511
580
- var result = variables . Select ( variable => this . CreateVariableFromVariableModel ( variable , automationAccountName ) ) . ToList ( ) ;
581
-
582
- IList < AutomationManagement . Models . EncryptedVariable > encryptedVariables = AutomationManagementClient . ContinuationTokenHandler (
583
- skipToken =>
584
- {
585
- var response = this . automationManagementClient . EncryptedVariables . List (
586
- automationAccountName ) ;
587
- return new ResponseWithSkipToken < AutomationManagement . Models . EncryptedVariable > (
588
- response , response . EncryptedVariables ) ;
589
- } ) ;
590
-
591
- result . AddRange ( encryptedVariables . Select ( variable => this . CreateVariableFromVariableModel ( variable , automationAccountName ) ) . ToList ( ) ) ;
592
-
593
- return result ;
512
+ return variables . Select ( variable => this . CreateVariableFromVariableModel ( variable , automationAccountName ) ) . ToList ( ) ;
594
513
}
595
514
#endregion
596
515
@@ -1581,14 +1500,6 @@ private Variable CreateVariableFromVariableModel(AutomationManagement.Models.Var
1581
1500
return new Variable ( variable , automationAccountName ) ;
1582
1501
}
1583
1502
1584
- private Variable CreateVariableFromVariableModel ( AutomationManagement . Models . EncryptedVariable variable , string automationAccountName )
1585
- {
1586
- Requires . Argument ( "variable" , variable ) . NotNull ( ) ;
1587
-
1588
- return new Variable ( variable , automationAccountName ) ;
1589
- }
1590
-
1591
-
1592
1503
private AutomationManagement . Models . Schedule GetScheduleModel ( string automationAccountName , string scheduleName )
1593
1504
{
1594
1505
AutomationManagement . Models . Schedule scheduleModel ;
0 commit comments