@@ -454,7 +454,7 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
454454 var rdcprop = new RunbookCreateOrUpdateDraftProperties ( )
455455 {
456456 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 ,
458458 LogProgress = logProgress . HasValue && logProgress . Value ,
459459 LogVerbose = logVerbose . HasValue && logVerbose . Value ,
460460 Draft = new RunbookDraft ( ) ,
@@ -476,7 +476,6 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
476476
477477 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 )
478478 {
479-
480479 var fileExtension = Path . GetExtension ( runbookPath ) ;
481480
482481 if ( 0 !=
@@ -492,14 +491,12 @@ public Runbook ImportRunbook(string resourceGroupName, string automationAccountN
492491
493492 // if graph runbook make sure type is not null and has right value
494493 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 ) ) )
497495 {
498496 throw new ResourceCommonException ( typeof ( Runbook ) ,
499497 string . Format ( CultureInfo . CurrentCulture , Resources . InvalidRunbookTypeForExtension , fileExtension ) ) ;
500498 }
501499
502-
503500 var runbookName = Path . GetFileNameWithoutExtension ( runbookPath ) ;
504501
505502 if ( String . IsNullOrWhiteSpace ( name ) == false )
@@ -1786,7 +1783,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
17861783 outputFolderFullPath = this . ValidateAndGetFullPath ( outputFolder ) ;
17871784 }
17881785
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 ;
17901787
17911788 var outputFilePath = outputFolderFullPath + "\\ " + runbookName + fileExtension ;
17921789
@@ -1803,6 +1800,13 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
18031800 return new DirectoryInfo ( runbookName + fileExtension ) ;
18041801 }
18051802
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+
18061810 #endregion
18071811 }
18081812}
0 commit comments