Azure Functions

Deploying to Azure Functions

Install integrations packages:

To get the Slackbot HttpTrigger at /api/slack/event in your Azure Functions host:

$ dotnet add package Slackbot.Net.Azure.Functions

To bridge Azure Functions & ASP.NET Core:

$ dotnet add package Slackbot.Net.Azure.Functions

Wire it up

Secret function integration sauce found in ConfigureFunctionsWebApplication:

Program.cs
var host = new HostBuilder()
    .ConfigureServices(s =>
    {
        s.AddAuthentication()
         .AddSlackbotEvents(c =>
            c.SigningSecret = Environment.GetEnvironmentVariable("CLIENT_SIGNING_SECRET")
        );
        s.AddSlackBotEvents();
    })
    .ConfigureFunctionsWebApplication(a => a.UseSlackbot())
    .Build();
 
await host.RunAsync();

Azure specifics

⚠️

The integration package only supports the Azure Function dotnet-isolated runtime!

Important Azure Site config to run as dotnet-isolated:

Not specific to Slackbot.NET, but necessary settings to run dotnet-isolated functions:

  • AzureWebJobsFeatureFlag: EnableHttpProxying - requirement as of preview2 of the ASP.NET Core integration package
  • FUNCTIONS_WORKER_RUNTIME: dotnet-isolated – to set the isolated mode
  • linuxFxVersion: DOTNET|6.0 – Just beause I'm deploying to Linux

Azure functions config

Deployment to Azure:

$ func azure functionapp publish $FUNCTION_APP_NAME

A sample function app can also be found in the /Samples folder in GitHub. See Samples.