Skip to content

Commit

Permalink
Updated docs and version number
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesRandall committed Dec 22, 2019
1 parent 7940add commit 1e7defa
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<CommonPackageVersion>4.0.25-beta.1</CommonPackageVersion>
<CommonPackageVersion>4.0.26-beta.2</CommonPackageVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>FunctionMonkey.Compiler</id>
<version>4.0.25-beta.1</version>
<version>4.0.26-beta.2</version>
<authors>James Randall</authors>
<description>Generates Azure Functions from command registrations</description>
<licenseUrl>https://raw.githubusercontent.com/JamesRandall/FunctionMonkey/master/LICENSE</licenseUrl>
Expand Down
70 changes: 69 additions & 1 deletion docfx/guides/eventhubs/eventhubs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
# Event Hubs

Docs coming soon
## Getting Started

First begin by creating an empty Azure Functions v2 project and then install the core nuget packages for Function Monkey:

Install-Package FunctionMonkey
Install-Package FunctionMonkey.Compiler

You will also need to add the Service Bus trigger bindings:

Install-Package Microsoft.Azure.WebJobs.Extensions.EventHubs

Now create a folder in the solution called commands and create a class called Analytic:

public class Analytic : ICommand
{
public string Fqn { get; set; }

public int Value { get; set; }
}

Next create a folder in the solution called Handlers and create a class called AnalyticHandler:

internal class AnalyticHandler : ICommandHandler<Analytic>
{
public Task ExecuteAsync(Analytic analytic)
{
// We won't really send an email from this sample
return Task.CompletedTask;
}
}

And now we'll create our function app configuration in the root of the project that registers the command handler and registers the command with a service bus queue:

public class FunctionAppConfiguration : IFunctionAppConfiguration
{
private const string EventHubName = "analyticHub";
public void Build(IFunctionHostBuilder builder)
{
builder
.Setup((serviceCollection, commandRegistry) =>
commandRegistry.Register<Analytic>()
)
.Functions(functions => functions
.EventHub(eventHub => eventHub
.EventHubFunction<Analytic>(EventHubName)
)
);
}
}

Finally we need to create an entry in local.settings.json for the Service Bus connection string:

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
"eventHubConnectionString": "<connection string>"
}
}

And that's it! If you run this project having created a queue called sendEmailQueue and use a real connection string you'll find that the _AnalyticHandler__ is invoked for each item you place on the event hub.

Note that it is possible to omit the connection setting name - see [default connection settings](/crosscutting/connectionStrings.md) for more details.

## Validation

If you want to validate the queue messages as you recieve them then validation is supported and is [documented here](/crosscutting/validation.html).
6 changes: 6 additions & 0 deletions docfx/guides/outputBindings/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ All the output bindings are available through the .OutputTo property on each Fun
* Storage Table
* Cosmos
* SignalR (both message and action)
* Event Hubs

An example of each in use is shown below:

Expand Down Expand Up @@ -68,6 +69,11 @@ An example of each in use is shown below:
.OutputTo.SignalRGroup("myHub")
)

.HttpRoute("recordMetric", route => route
.HttpFunction<RecordMetricCommand>(HttpMethod.Put)
.OutputTo.EventHub("myEventHub")
)

.CosmosDb(cosmos => cosmos
.ChangeFeedFunction<CosmosTriggerTableOutputCommand>("mycollection", "mydatabase)
.OutputTo.StorageTable("mystoragetable)
Expand Down
1 change: 1 addition & 0 deletions pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dotnet pack ./Source/FunctionMonkey.FluentValidation/FunctionMonkey.FluentValida
dotnet pack ./Source/FunctionMonkey.SignalR/FunctionMonkey.SignalR.csproj --output ./ --configuration Release
dotnet pack ./Source/FunctionMonkey.Testing/FunctionMonkey.Testing.csproj --output ./ --configuration Release
dotnet pack ./Source/FunctionMonkey.TokenValidator/FunctionMonkey.TokenValidator.csproj --output ./ --configuration Release
dotnet pack ./Source/FunctionMonkey.AspNetCore/FunctionMonkey.AspNetCore.csproj --output ./ --configuration Release
dotnet pack ./Source/FunctionMonkey.FSharp/FunctionMonkey.FSharp.fsproj --output ./ --configuration Release

0 comments on commit 1e7defa

Please sign in to comment.