public override async Task RunAsync()
        {
            await PreRunConditions();

            Utilities.PrintLogo();
            Utilities.PrintVersion();

            var settings = SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);

            (var listenUri, var baseUri, var certificate) = await Setup();

            IWebHost host = await BuildWebHost(settings, listenUri, baseUri, certificate);

            var runTask = host.RunAsync();

            var hostService = host.Services.GetRequiredService <WebJobsScriptHostService>();

            await hostService.DelayUntilHostReady();

            var scriptHost  = hostService.Services.GetRequiredService <IScriptJobHost>();
            var httpOptions = hostService.Services.GetRequiredService <IOptions <HttpOptions> >();

            DisplayHttpFunctionsInfo(scriptHost, httpOptions.Value, baseUri);
            DisplayDisabledFunctions(scriptHost);

            await runTask;
        }
        public override async Task RunAsync()
        {
            PreRunConditions();
            Utilities.PrintLogo();

            var settings = SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);

            (var baseAddress, var certificate) = Setup();

            IWebHost host = await BuildWebHost(settings, baseAddress, certificate);

            var runTask = host.RunAsync();

            var manager = host.Services.GetRequiredService <WebScriptHostManager>();
            await manager.DelayUntilHostReady();

            ColoredConsole.WriteLine($"Listening on {baseAddress}");
            ColoredConsole.WriteLine("Hit CTRL-C to exit...");

            DisplayHttpFunctionsInfo(manager, baseAddress);
            DisplayDisabledFunctions(manager);
            await SetupDebuggerAsync(baseAddress);

            await runTask;
        }
        public override async Task RunAsync()
        {
            var workerRuntime = WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(_secretsManager);

            if (workerRuntime == WorkerRuntime.None)
            {
                throw new CliException("your worker runtime is not set. As of 2.0.1-beta.26 a worker runtime setting is required.\n" +
                                       $"Please run `func settings add {Constants.FunctionsWorkerRuntime} <option>`\n" +
                                       $"Available options: {WorkerRuntimeLanguageHelper.AvailableWorkersRuntimeString}");
            }

            await PreRunConditions(workerRuntime);

            Utilities.PrintLogo();

            var settings = SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);

            (var baseAddress, var certificate) = Setup();

            IWebHost host = await BuildWebHost(settings, workerRuntime, baseAddress, certificate);

            var runTask = host.RunAsync();

            var manager = host.Services.GetRequiredService <WebScriptHostManager>();
            await manager.DelayUntilHostReady();

            ColoredConsole.WriteLine($"Listening on {baseAddress}");
            ColoredConsole.WriteLine("Hit CTRL-C to exit...");

            DisplayHttpFunctionsInfo(manager, baseAddress);
            DisplayDisabledFunctions(manager);
            await SetupDebuggerAsync(baseAddress);

            await runTask;
        }
Ejemplo n.º 4
0
        public static ExtensionBundleOptions GetExtensionBundleOptions(ScriptApplicationHostOptions hostOptions = null)
        {
            hostOptions = hostOptions ?? SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);
            IConfigurationRoot configuration = Utilities.BuildHostJsonConfigutation(hostOptions);
            var configurationHelper          = new ExtensionBundleConfigurationHelper(configuration, SystemEnvironment.Instance);
            var options = new ExtensionBundleOptions();

            configurationHelper.Configure(options);
            return(options);
        }
        public static ExtensionBundleOptions GetExtensionBundleOptions(ScriptApplicationHostOptions hostOptions = null)
        {
            hostOptions = hostOptions ?? SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);
            IConfigurationBuilder builder = new ConfigurationBuilder();

            builder.Add(new HostJsonFileConfigurationSource(hostOptions, SystemEnvironment.Instance, loggerFactory: NullLoggerFactory.Instance));
            var configuration = builder.Build();

            var configurationHelper = new ExtensionBundleConfigurationHelper(configuration, SystemEnvironment.Instance);
            var options             = new ExtensionBundleOptions();

            configurationHelper.Configure(options);
            return(options);
        }
Ejemplo n.º 6
0
        public override async Task RunAsync()
        {
            Utilities.PrintLogo();

            var scriptPath = ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory);
            var traceLevel = await ScriptHostHelpers.GetTraceLevel(scriptPath);

            var settings = SelfHostWebHostSettingsFactory.Create(traceLevel, scriptPath);


            var baseAddress = Setup();

            await ReadSecrets(scriptPath, baseAddress);

            var config = new HttpSelfHostConfiguration(baseAddress)
            {
                IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always,
                TransferMode             = TransferMode.Streamed,
                HostNameComparisonMode   = HostNameComparisonMode.Exact,
                MaxReceivedMessageSize   = 1 * 1024 * 1024 * 100 // 1 byte * 1,024 * 1,024 * 100 = 100 MB (or 104,857,600 bytes)
            };

            if (!string.IsNullOrEmpty(CorsOrigins))
            {
                var cors = new EnableCorsAttribute(CorsOrigins, "*", "*");
                config.EnableCors(cors);
            }
            config.Formatters.Add(new JsonMediaTypeFormatter());

            Environment.SetEnvironmentVariable("EDGE_NODE_PARAMS", $"--debug={NodeDebugPort}", EnvironmentVariableTarget.Process);

            WebApiConfig.Initialize(config, settings: settings);

            using (var httpServer = new HttpSelfHostServer(config))
            {
                await httpServer.OpenAsync();

                ColoredConsole.WriteLine($"Listening on {baseAddress}");
                ColoredConsole.WriteLine("Hit CTRL-C to exit...");
                await PostHostStartActions(config);

                await Task.Delay(-1);

                await httpServer.CloseAsync();
            }
        }
Ejemplo n.º 7
0
        public override async Task RunAsync()
        {
            Utilities.PrintLogo();

            var scriptPath = IgnoreHostJsonNotFound
                ? Environment.CurrentDirectory
                : ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory);
            var settings = SelfHostWebHostSettingsFactory.Create(ConsoleTraceLevel, scriptPath);

            ReadSecrets();
            CheckHostJsonId();

            var baseAddress = Setup();

            var config = new HttpSelfHostConfiguration(baseAddress)
            {
                IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always,
                TransferMode             = TransferMode.Streamed
            };

            var cors = new EnableCorsAttribute(CorsOrigins, "*", "*");

            config.EnableCors(cors);
            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());

            Environment.SetEnvironmentVariable("EDGE_NODE_PARAMS", $"--debug={NodeDebugPort}", EnvironmentVariableTarget.Process);

            WebApiConfig.Initialize(config, settings: settings);

            using (var httpServer = new HttpSelfHostServer(config))
            {
                await httpServer.OpenAsync();

                ColoredConsole.WriteLine($"Listening on {baseAddress}");
                ColoredConsole.WriteLine("Hit CTRL-C to exit...");
                await PostHostStartActions(config);

                await Task.Delay(-1);

                await httpServer.CloseAsync();
            }
        }
Ejemplo n.º 8
0
        public override async Task RunAsync()
        {
            await PreRunConditions();

            var isVerbose = VerboseLogging.HasValue && VerboseLogging.Value;

            if (isVerbose || EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.DisplayLogo))
            {
                Utilities.PrintLogo();
            }

            // Suppress AspNetCoreSupressStatusMessages
            EnvironmentHelper.SetEnvironmentVariableAsBoolIfNotExists(Constants.AspNetCoreSupressStatusMessages);

            Utilities.PrintVersion();

            ScriptApplicationHostOptions hostOptions = SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);

            ValidateAndBuildHostJsonConfigurationIfFileExists(hostOptions);

            (var listenUri, var baseUri, var certificate) = await Setup();

            IWebHost host = await BuildWebHost(hostOptions, listenUri, baseUri, certificate);

            var runTask = host.RunAsync();

            var hostService = host.Services.GetRequiredService <WebJobsScriptHostService>();

            await hostService.DelayUntilHostReady();

            var scriptHost  = hostService.Services.GetRequiredService <IScriptJobHost>();
            var httpOptions = hostService.Services.GetRequiredService <IOptions <HttpOptions> >();

            if (scriptHost != null && scriptHost.Functions.Any())
            {
                DisplayFunctionsInfoUtilities.DisplayFunctionsInfo(scriptHost.Functions, httpOptions.Value, baseUri);
            }
            if (VerboseLogging == null || !VerboseLogging.Value)
            {
                ColoredConsole.WriteLine(AdditionalInfoColor("For detailed output, run func with --verbose flag."));
            }
            await runTask;
        }
Ejemplo n.º 9
0
        public override async Task RunAsync()
        {
            var workerRuntime = WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(_secretsManager);

            if (workerRuntime == WorkerRuntime.None)
            {
                ColoredConsole.WriteLine(WarningColor("your worker runtime is not set. As of 2.0.1-beta.26 a worker runtime setting is required."))
                .WriteLine(WarningColor($"Please run `{AdditionalInfoColor($"func settings add {Constants.FunctionsWorkerRuntime} <option>")}` or add {Constants.FunctionsWorkerRuntime} to your local.settings.json"))
                .WriteLine(WarningColor($"Available options: {WorkerRuntimeLanguageHelper.AvailableWorkersRuntimeString}"));
            }

            await PreRunConditions(workerRuntime);

            Utilities.PrintLogo();
            Utilities.PrintVersion();

            var settings = SelfHostWebHostSettingsFactory.Create(Environment.CurrentDirectory);

            (var listenUri, var baseUri, var certificate) = await Setup();

            IWebHost host = await BuildWebHost(settings, workerRuntime, listenUri, certificate);

            var runTask = host.RunAsync();

            var hostService = host.Services.GetRequiredService <WebJobsScriptHostService>();

            await hostService.DelayUntilHostReady();

            ColoredConsole.WriteLine($"Listening on {listenUri}");
            ColoredConsole.WriteLine("Hit CTRL-C to exit...");

            var scriptHost  = hostService.Services.GetRequiredService <IScriptJobHost>();
            var httpOptions = hostService.Services.GetRequiredService <IOptions <HttpOptions> >();

            DisplayHttpFunctionsInfo(scriptHost, httpOptions.Value, baseUri);
            DisplayDisabledFunctions(scriptHost);
            await SetupDebuggerAsync(baseUri);

            await runTask;
        }