@@ -454,7 +454,7 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
454
454
var rdcprop = new RunbookCreateOrUpdateDraftProperties ( )
455
455
{
456
456
Description = description ,
457
- RunbookType = String . IsNullOrWhiteSpace ( type ) ? RunbookTypeEnum . Script : ( 0 == string . Compare ( type , Constants . RunbookType . PowerShellWorkflow , StringComparison . OrdinalIgnoreCase ) ) ? RunbookTypeEnum . Script : type ,
457
+ RunbookType = String . IsNullOrWhiteSpace ( type ) ? RunbookTypeEnum . Script : type ,
458
458
LogProgress = logProgress . HasValue && logProgress . Value ,
459
459
LogVerbose = logVerbose . HasValue && logVerbose . Value ,
460
460
Draft = new RunbookDraft ( ) ,
@@ -476,7 +476,6 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
476
476
477
477
public Runbook ImportRunbook ( string resourceGroupName , string automationAccountName , string runbookPath , string description , IDictionary tags , string type , bool ? logProgress , bool ? logVerbose , bool published , bool overwrite , string name )
478
478
{
479
-
480
479
var fileExtension = Path . GetExtension ( runbookPath ) ;
481
480
482
481
if ( 0 !=
@@ -492,14 +491,12 @@ public Runbook ImportRunbook(string resourceGroupName, string automationAccountN
492
491
493
492
// if graph runbook make sure type is not null and has right value
494
493
if ( 0 == string . Compare ( fileExtension , Constants . SupportedFileExtensions . Graph , StringComparison . OrdinalIgnoreCase )
495
- && string . IsNullOrWhiteSpace ( type )
496
- && ( 0 != string . Compare ( type , Constants . RunbookType . Graph , StringComparison . OrdinalIgnoreCase ) ) )
494
+ && ( string . IsNullOrWhiteSpace ( type ) || ! IsGraphRunbook ( type ) ) )
497
495
{
498
496
throw new ResourceCommonException ( typeof ( Runbook ) ,
499
497
string . Format ( CultureInfo . CurrentCulture , Resources . InvalidRunbookTypeForExtension , fileExtension ) ) ;
500
498
}
501
499
502
-
503
500
var runbookName = Path . GetFileNameWithoutExtension ( runbookPath ) ;
504
501
505
502
if ( String . IsNullOrWhiteSpace ( name ) == false )
@@ -1786,7 +1783,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
1786
1783
outputFolderFullPath = this . ValidateAndGetFullPath ( outputFolder ) ;
1787
1784
}
1788
1785
1789
- var fileExtension = ( 0 == string . Compare ( runbookType , Constants . RunbookType . Graph , StringComparison . OrdinalIgnoreCase ) ) ? Constants . SupportedFileExtensions . Graph : Constants . SupportedFileExtensions . PowerShellScript ;
1786
+ var fileExtension = IsGraphRunbook ( runbookType ) ? Constants . SupportedFileExtensions . Graph : Constants . SupportedFileExtensions . PowerShellScript ;
1790
1787
1791
1788
var outputFilePath = outputFolderFullPath + "\\ " + runbookName + fileExtension ;
1792
1789
@@ -1803,6 +1800,13 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
1803
1800
return new DirectoryInfo ( runbookName + fileExtension ) ;
1804
1801
}
1805
1802
1803
+ private static bool IsGraphRunbook ( string runbookType )
1804
+ {
1805
+ return ( string . Equals ( runbookType , Constants . RunbookType . Graph , StringComparison . OrdinalIgnoreCase ) ||
1806
+ string . Equals ( runbookType , Constants . RunbookType . GraphPowerShell , StringComparison . OrdinalIgnoreCase ) ||
1807
+ string . Equals ( runbookType , Constants . RunbookType . GraphPowerShellWorkflow , StringComparison . OrdinalIgnoreCase ) ) ;
1808
+ }
1809
+
1806
1810
#endregion
1807
1811
}
1808
1812
}
0 commit comments