Exemple #1
0
        public override void Configure(
            IFunctionsHostBuilder builder)
        {
            // Settings for event grid

            var eventGridMessageAddOptions =
                new EventGridMessageAddOptions
            {
                TopicEndpoint = Environment.GetEnvironmentVariable("EventGridMessageAddOptions:TopicEndpoint"),
                TopicKey      = Environment.GetEnvironmentVariable("EventGridMessageAddOptions:TopicKey")
            };

            builder.Services
            .AddSingleton(eventGridMessageAddOptions);

            // Settings for event hub

            var eventHubMessageAddOptions =
                new EventHubMessageAddOptions
            {
                ConnectionString = Environment.GetEnvironmentVariable("EventHubMessageAddOptions:ConnectionString")
            };

            builder.Services
            .AddSingleton(eventHubMessageAddOptions);

            // Settings for service bus

            var serviceBusMessageSenderOptions =
                new ServiceBusMessageAddOptions
            {
                ConnectionString = Environment.GetEnvironmentVariable("ServiceBusMessageAddOptions:ConnectionString")
            };

            builder.Services
            .AddSingleton(serviceBusMessageSenderOptions);

            // Settings for storage queue

            var storageQueueMessageAddOptions =
                new StorageQueueMessageAddOptions
            {
                ConnectionString = Environment.GetEnvironmentVariable("StorageQueueMessageAddOptions:ConnectionString")
            };

            builder.Services
            .AddSingleton(storageQueueMessageAddOptions);

            // Choose your add message service

            builder.Services
            .AddSingleton <IMessageAdd, EventGridMessageAdd>();
            //builder.Services
            //    .AddSingleton<IMessageAdd, EventHubMessageAdd>();
            //builder.Services
            //    .AddSingleton<IMessageAdd, ServiceBusMessageAdd>();
            //builder.Services
            //    .AddSingleton<IMessageAdd, StorageQueueMessageAdd>();
            //builder.Services
            //    .AddSingleton<IMessageAdd, FakeMessageAdd>();
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Settings for event grid

            var eventGridMessageAddOptions =
                new EventGridMessageAddOptions
            {
                TopicEndpoint = Configuration["EventGridMessageAddOptions:TopicEndpoint"],
                TopicKey      = Configuration["EventGridMessageAddOptions:TopicKey"]
            };

            services
            .AddSingleton(eventGridMessageAddOptions);

            // Settings for event hub

            var eventHubMessageAddOptions =
                new EventHubMessageAddOptions
            {
                ConnectionString = Configuration["EventHubMessageAddOptions:ConnectionString"]
            };

            services
            .AddSingleton(eventHubMessageAddOptions);

            // Settings for service bus

            var serviceBusMessageSenderOptions =
                new ServiceBusMessageAddOptions
            {
                ConnectionString = Configuration["ServiceBusMessageAddOptions:ConnectionString"]
            };

            services
            .AddSingleton(serviceBusMessageSenderOptions);

            // Settings for storage queue

            var storageQueueMessageAddOptions =
                new StorageQueueMessageAddOptions
            {
                ConnectionString = Configuration["StorageQueueMessageAddOptions:ConnectionString"]
            };

            services
            .AddSingleton(storageQueueMessageAddOptions);

            // Choose your add message service

            services
            .AddSingleton <IMessageAdd, EventGridMessageAdd>();
            //services
            //    .AddSingleton<IMessageAdd, EventHubMessageAdd>();
            //services
            //    .AddSingleton<IMessageAdd, ServiceBusMessageAdd>();
            //services
            //    .AddSingleton<IMessageAdd, StorageQueueMessageAdd>();
            //services
            //    .AddSingleton<IMessageAdd, FakeMessageAdd>();

            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }