This project contains an implementation of a custom output binding for Azure Functions. Target for the binding is the SAP Event Mesh
Build the project from scratch via
dotnet clean
dotnet build
In order to make the binding available to your Azure Function, you must execute the following steps:
- Create an Azure Functions project e. g. via VSCode Azure Function extension with an HTTP triggered Azure Function project in it
- Add a folder
extension
to your Azure Functions project. - Copy the
dll
file of the built extension into the folder. - Remove the
extensionbundle
section from thehost.json
file. - Initialize the Azure Functions project with a
extensions.csproj
file viafunc extensions sync
- Add the dependencies to the
extensions.csproj
file namely:
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.27" />
<PackageReference Include="RestSharp" Version="106.12.0" />
- Execute
func extensions install
. You can check if this was successful by checking the fileextension.json
in thebin
directory. You should now have an entry for the Event Mesh binding in there. - Add the output binding to the function in the
function.json
{
"type": "EventMesh",
"direction": "out",
"name": "EventMeshMessage",
"EventMeshTokenEndpoint": "%EventMeshTokenEndpoint%",
"EventMeshClientId": "%EventMeshClientId%",
"EventMeshClientSecret": "%EventMeshClientSecret%",
"EventMeshGrantType": "%EventMeshGrantType%",
"EventMeshRestBaseEndpoint": "%EventMeshRestBaseEndpoint%",
"EventMeshQueueName": "%EventMeshQueueName%"
}
- Add the connection values for the event mesh into the
local settings.json
like:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"EventMeshTokenEndpoint": "<YOUR EVENT MESH TOKEN ENDPOINT>",
"EventMeshClientId": "<YOUR EVENT MESH CLIENT ID>",
"EventMeshClientSecret": "<YOUR EVENT MESH CLIENT SECRET>",
"EventMeshGrantType": "client_credentials",
"EventMeshRestBaseEndpoint": "<YOUR EVENT MESH REST ENDPOINT>",
"EventMeshQueueName": "<YOUR EVENT MESH QUEUE NAME>"
}
}
Now you are set to run the function and put messages into a queue in the SAP Event Mesh.
You find a sample function in this GitHub repository: link