/azure-functions-rabbitmq-extension

RabbitMQ extension for Azure Functions

Primary LanguageC#MIT LicenseMIT

Branch Status
dev Build Status

RabbitMQ Binding Support for Azure Functions

NuGet Package Microsoft.Azure.WebJobs.Extensions.RabbitMQ

Please note that the RabbitMQ extension is fully supported on Premium and Dedicated plans. Consumption is not supported. The Azure Functions RabbitMQ Binding extensions allow you to send and receive messages using the RabbitMQ API but by writing Functions code. The RabbitMQ output binding sends messages to a specific queue. The RabbitMQ trigger fires when it receives a message from a specific queue.

RabbitMQ Documentation for the .NET Client

To get started with developing with this extension, make sure you first set up a RabbitMQ endpoint. Then you can go ahead and begin developing your functions in C#, C# Script, JavaScript, Python or Java.

Samples

See the repository wiki for more detailed samples of bindings to different types.

public static void RabbitMQTrigger_RabbitMQOutput(
    [RabbitMQTrigger("queue", ConnectionStringSetting = "RabbitMQConnectionAppSetting")] string inputMessage,
    [RabbitMQ(
        ConnectionStringSetting = "RabbitMQConnectionAppSetting",
        QueueName = "hello")] out string outputMessage,
    ILogger logger)
{
    outputMessage = inputMessage;
    logger.LogInformation($"RabbitMQ output binding function sent message: {outputMessage}");
}

The above sample waits on a trigger from the queue named "queue" connected to the connection string value of key "RabbitMQConnectionAppSetting." The output binding takes the messages from the trigger queue and outputs them to queue "hello" connected to the connection configured by the key "RabbitMQConnectionAppSetting". When running locally, add the connection string setting to local.settings.json file. When running in Azure, add this setting as Application Setting for your app.

Properties

Property Name Description Example
ConnectionStringSetting The connection string for the RabbitMQ queue amqp://user:password@url:port
QueueName The name of the source or destination queue.
HostName (ignored if using ConnectionStringSetting) Hostname of the queue 10.26.45.210
UserName (ignored if using ConnectionStringSetting) User name to access queue user
Password (ignored if using ConnectionStringSetting) Password to access queue password

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.