-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
33 lines (27 loc) · 1.07 KB
/
Program.cs
File metadata and controls
33 lines (27 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Azure.Identity;
using Azure.Messaging.ServiceBus;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices((context, services) =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddAzureClients(builder =>
{
var serviceBusNamespace = context.Configuration["ServiceBusConnection:fullyQualifiedNamespace"];
builder.AddServiceBusClientWithNamespace(serviceBusNamespace);
var queueName = context.Configuration["ServiceBusQueueName"];
services.AddSingleton(provider =>
{
var client = provider.GetRequiredService<ServiceBusClient>();
return client.CreateSender(queueName);
});
builder.UseCredential(new DefaultAzureCredential());
});
})
.Build();
host.Run();