@@ -439,22 +439,22 @@ internal static bool TryReadFunctionConfig(string scriptDir, out string json, IF
439
439
return true ;
440
440
}
441
441
442
- internal static void VerifyFunctionsMatchSpecifiedLanguage ( IEnumerable < FunctionMetadata > functions , string currentRuntimeLanguage )
442
+ internal static void VerifyFunctionsMatchSpecifiedLanguage ( IEnumerable < FunctionMetadata > functions , string workerRuntime )
443
443
{
444
- if ( ! IsSingleLanguage ( functions , currentRuntimeLanguage ) )
444
+ if ( ! IsSingleLanguage ( functions , workerRuntime ) )
445
445
{
446
- if ( string . IsNullOrEmpty ( currentRuntimeLanguage ) )
446
+ if ( string . IsNullOrEmpty ( workerRuntime ) )
447
447
{
448
448
throw new HostInitializationException ( $ "Found functions with more than one language. Select a language for your function app by specifying { LanguageWorkerConstants . FunctionWorkerRuntimeSettingName } AppSetting") ;
449
449
}
450
450
else
451
451
{
452
- throw new HostInitializationException ( $ "Did not find functions with language [{ currentRuntimeLanguage } ].") ;
452
+ throw new HostInitializationException ( $ "Did not find functions with language [{ workerRuntime } ].") ;
453
453
}
454
454
}
455
455
}
456
456
457
- internal static bool IsSingleLanguage ( IEnumerable < FunctionMetadata > functions , string currentRuntimeLanguage )
457
+ internal static bool IsSingleLanguage ( IEnumerable < FunctionMetadata > functions , string workerRuntime )
458
458
{
459
459
if ( functions == null )
460
460
{
@@ -465,54 +465,36 @@ internal static bool IsSingleLanguage(IEnumerable<FunctionMetadata> functions, s
465
465
{
466
466
return true ;
467
467
}
468
- if ( string . IsNullOrEmpty ( currentRuntimeLanguage ) )
468
+ if ( string . IsNullOrEmpty ( workerRuntime ) )
469
469
{
470
470
return functionsListWithoutProxies . Select ( f => f . Language ) . Distinct ( ) . Count ( ) <= 1 ;
471
471
}
472
- return ContainsFunctionWithWorkerRuntime ( functionsListWithoutProxies , currentRuntimeLanguage ) ;
473
- }
474
-
475
- internal static bool ShouldInitializeFunctionDispatcher ( IEnvironment environment , IEnumerable < FunctionMetadata > functions , string workerRuntime )
476
- {
477
- if ( environment . GetEnvironmentVariable ( EnvironmentSettingNames . AzureWebsitePlaceholderMode ) == "1" )
478
- {
479
- return false ;
480
- }
481
- if ( ! string . IsNullOrEmpty ( workerRuntime ) && workerRuntime . Equals ( LanguageWorkerConstants . DotNetLanguageWorkerName , StringComparison . OrdinalIgnoreCase ) )
482
- {
483
- return false ;
484
- }
485
- var functionsListWithoutProxies = functions ? . Where ( f => f . IsProxy == false ) ;
486
- if ( ! string . IsNullOrEmpty ( workerRuntime ) && ContainsFunctionWithWorkerRuntime ( functionsListWithoutProxies , workerRuntime ) )
487
- {
488
- return true ;
489
- }
490
- return ContainsNonDotNetFunctions ( functionsListWithoutProxies ) ;
472
+ return ContainsFunctionWithWorkerRuntime ( functionsListWithoutProxies , workerRuntime ) ;
491
473
}
492
474
493
475
internal static string GetWorkerRuntime ( IEnumerable < FunctionMetadata > functions )
494
476
{
495
- var functionsListWithoutProxies = functions ? . Where ( f => f . IsProxy == false ) ;
496
- string functionLanguage = functionsListWithoutProxies . FirstOrDefault ( ) ? . Language ;
497
- if ( IsDotNetLanguageFunction ( functionLanguage ) )
477
+ if ( IsSingleLanguage ( functions , null ) )
498
478
{
499
- return LanguageWorkerConstants . DotNetLanguageWorkerName ;
479
+ var functionsListWithoutProxies = functions ? . Where ( f => f . IsProxy == false ) ;
480
+ string functionLanguage = functionsListWithoutProxies . FirstOrDefault ( ) ? . Language ;
481
+ if ( IsDotNetLanguageFunction ( functionLanguage ) )
482
+ {
483
+ return LanguageWorkerConstants . DotNetLanguageWorkerName ;
484
+ }
485
+ return functionLanguage ;
500
486
}
501
- return functionLanguage ;
487
+ return null ;
502
488
}
503
489
504
- private static bool ContainsNonDotNetFunctions ( IEnumerable < FunctionMetadata > functions )
490
+ public static bool IsDotNetLanguageFunction ( string functionLanguage )
505
491
{
506
- if ( functions != null && functions . Any ( ) )
507
- {
508
- return functions . Any ( f => ! dotNetLanguages . Contains ( f . Language , StringComparer . OrdinalIgnoreCase ) ) ;
509
- }
510
- return false ;
492
+ return dotNetLanguages . Any ( lang => string . Equals ( lang , functionLanguage , StringComparison . OrdinalIgnoreCase ) ) ;
511
493
}
512
494
513
- public static bool IsDotNetLanguageFunction ( string functionLanguage )
495
+ public static bool IsSupportedRuntime ( string workerRuntime , IEnumerable < WorkerConfig > workerConfigs )
514
496
{
515
- return dotNetLanguages . Any ( lang => string . Equals ( lang , functionLanguage , StringComparison . OrdinalIgnoreCase ) ) ;
497
+ return workerConfigs . Any ( config => string . Equals ( config . Language , workerRuntime , StringComparison . OrdinalIgnoreCase ) ) ;
516
498
}
517
499
518
500
private static bool ContainsFunctionWithWorkerRuntime ( IEnumerable < FunctionMetadata > functions , string workerRuntime )
0 commit comments