Skip to content

webmotions/Azure.WebJobs.Extensions

Repository files navigation

Azure WebJobs Extensions

The Azure WebJobs Extensions is a project that includes various binding extensions for the Azure WebJobs SDK.

Master Dev
Build Status Build Status

Extensions

Slack

A Slack binding that allows you to easily send rich slack messages after your job functions complete. This extension lives in the WebMotions.Azure.WebJobs.Extensions.Slack package. Get started easily by either using the binding variable WebHookUrl or by using the app settings/environment variable AzureWebJobsSlackWebHookUrl. You can also use an API Key, by using the binding variable ApiKey or the app settings/environment variable AzureWebJobsSlackWebApiKey. Other options are available either through the binding attribute or directly in the SlackMessage class.

sample1

sample2

Installation

Official packages are available on NuGet.

Unofficial (dev) packages are available on MyGet

dotnet add package WebMotions.Azure.WebJobs.Extensions.Slack

Usage

using WebMotions.Azure.WebJobs.Extensions.Slack;

[FunctionName("YourFunction")]
public async Task Run(
	[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req,
	[Slack(WebHookUrl = "https://hooks.slack.com/services/XXXXXXXX/XXXXXXXXXX/XXXXXXXXX")] IAsyncCollector<SlackMessage> messages,
	ILogger logger)
{
	var message = new SlackMessage();
	
	// configure your message
	
	await messages.AddAsync(message);
}

Adding the binding to your function automatically registers the extension. If you want more options, you can register the Slack extensions, using builder.AddSlack() in your startup code. For more information on the Slack binding, see the Slack samples.

Limitations

Attachments were not added of part of this extension. The reason behind this is that Slack considers attachments a legacy part of the messaging functionality: they may change in the future, in ways that reduce their visibility or utility. See the documentation for more information.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT