internal static string GetFunctionBaseFolder()

in src/Microsoft.Azure.WebJobs.Extensions.Kafka/Config/AzureFunctionsFileHelper.cs [52:75]


        internal static string GetFunctionBaseFolder()
        {
            if (!IsRunningAsFunctionInAzureOrContainer())
            {
                return null;
            }

            // When running in container the path will be defined at AzureWebJobsScriptRoot
            var azureWebJobsScriptRoot = Environment.GetEnvironmentVariable(AzureWebJobsScriptRootEnvVarName, EnvironmentVariableTarget.Process);
            if (!string.IsNullOrWhiteSpace(azureWebJobsScriptRoot))
            {
                return azureWebJobsScriptRoot;
            }

            // In Azure HOME contains the main folder where the function is located (windows) = D:\home
            // By default the Azure function will be located under D:\home\site\wwwroot
            var homeDir = Environment.GetEnvironmentVariable(AzureHomeEnvVarName, EnvironmentVariableTarget.Process);
            if (!string.IsNullOrWhiteSpace(homeDir))
            {
                return Path.Combine(homeDir, AzureDefaultFunctionPathPart1, AzureDefaultFunctionPathPart2);
            }

            return null;
        }