Esempio n. 1
0
        public static async Task <int> Main(string[] args)
        {
            string profilePath = DirHelper.GetTempPath();

            ProfileOptimization.SetProfileRoot(profilePath);
            ProfileOptimization.StartProfile("bicep.profile");
            Console.OutputEncoding = TemplateEmitter.UTF8EncodingWithoutBom;

            BicepDeploymentsInterop.Initialize();

            if (FeatureProvider.TracingEnabled)
            {
                Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            }

            // this event listener picks up SDK events and writes them to Trace.WriteLine()
            using (FeatureProvider.TracingEnabled ? AzureEventSourceListenerFactory.Create(FeatureProvider.TracingVerbosity) : null)
            {
                var program = new Program(new InvocationContext(
                                              new AzResourceTypeLoader(),
                                              Console.Out,
                                              Console.Error,
                                              features: null,
                                              clientFactory: null));

                // this must be awaited so dispose of the listener occurs in the continuation
                // rather than the sync part at the beginning of RunAsync()
                return(await program.RunAsync(args));
            }
        }
Esempio n. 2
0
        public async Task RunAsync(CancellationToken cancellationToken)
        {
            await server.Initialize(cancellationToken);

            server.LogInfo($"Running on processId {Environment.ProcessId}");

            if (FeatureProvider.TracingEnabled)
            {
                Trace.Listeners.Add(new ServerLogTraceListener(server));
            }

            using (FeatureProvider.TracingEnabled ? AzureEventSourceListenerFactory.Create(FeatureProvider.TracingVerbosity) : null)
            {
                var scheduler = server.GetRequiredService <IModuleRestoreScheduler>();
                scheduler.Start();

                await server.WaitForExit;
            }
        }