Skip to content

Commit

Permalink
Updating the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
keesschollaart81 committed Mar 25, 2018
1 parent 5b166af commit 3f28cd0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
This is a work-in-progress of a Mqtt Trigger for Azure Functions.

The code currently works as it is but I have to make it better configurable before I publish it as a NuGet Package. Things that have to be done:
- Unit Tests & Integration tests
- extensions.json is now manually created, which should not be needed
- Use ILogger instead of TraceWriter which currently does not output for some reason?
- Figure out if this is stable in the long run, will the connection persist days (currently tested for hours)
- Create more Unit Tests & Integration tests and get code coverage to >80%
- Use ILogger instead of TraceWriter which currently does not output on dev machine for some reason?
- Create demos for integrations with CloudMqtt.net and Azure IoT Hub

Expect a NuGet package halfway April '18.

[![Build Status](https://caseonline.visualstudio.com/_apis/public/build/definitions/4df87c38-5691-4d04-8373-46c830209b7e/11/badge)](https://caseonline.visualstudio.com/CaseOnline.Azure.WebJobs.Extensions.Mqtt/_build/index?definitionId=1)
[![BCH compliance](https://bettercodehub.com/edge/badge/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt?branch=master)](https://bettercodehub.com/)
Expand All @@ -15,14 +16,13 @@ The code currently works as it is but I have to make it better configurable befo
- Create an Azure Function using [Visual Studio](https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs) or using [Visual Studio Code](https://code.visualstudio.com/tutorials/functions-extension/getting-started)
- Make sure your ```Microsoft.NET.Sdk.Functions``` package version is 1.0.7 or higher
- Install the [CaseOnline.Azure.WebJobs.Extensions.Mqtt](https://www.nuget.org/packages/CaseOnline.Azure.WebJobs.Extensions.Mqtt/) NuGet package in you Functions Project
- Add an [extensions.json](./src/ExampleFunctions/extensions.json) to your Functions project root directory and [make sure it is copied to the build/publish folder](./src/ExampleFunctions/ExampleFunctions.csproj#L23-L25)
- This is temporary for now. This should not be needed, monitor [issue/bug here](https://github.com/Azure/Azure-Functions/issues/624))
- Add the Mqtt server settings to your 'local.settings.json' during development time or to your appsettings when running on Azure:
- MqttServer (just the dns/hostname)
- MqttUsername
- MqttPassword
- MqttPort (optional, defaults to 1883)
- MqttClientId (optional, defaults to a random Guid)
- When deploying/running on Azure set/ad the application-setting ```FUNCTIONS_EXTENSION_VERSION``` to ```beta```
- Add a ```MqttTrigger``` attribute to your function parameters:

```
Expand Down Expand Up @@ -55,6 +55,10 @@ Please find some samples here in the [sample project](./src/ExampleFunctions/).
## References
- [MQTTnet](https://github.com/chkr1011/MQTTnet)
## Roadmap
- 1.0.0 Initial release, april 2018
- 1.5.0 Output binding for publishing messages june 2018
## MIT License
Copyright (c) 2018 Kees Schollaart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ private MqttConfiguration GetConfigurationViaAttributeValues()
clientId = Guid.NewGuid().ToString();
}

var server = _nameResolver.Resolve(_mqttTriggerAttribute.ServerName ?? SettingsKeyForServer);
var server = _nameResolver.Resolve(_mqttTriggerAttribute.ServerName ?? SettingsKeyForServer);
if (string.IsNullOrEmpty(server)) throw new Exception("No server hostname configured, please set the server via the MqttTriggerAttribute, using the application settings via the Azure Portal or using the local.settings.json");

var username = _nameResolver.Resolve(_mqttTriggerAttribute.UsernameName ?? SettingsKeyForUsername);
var password = _nameResolver.Resolve(_mqttTriggerAttribute.PasswordName ?? SettingsKeyForPassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RepositoryUrl>https://github.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseUrl>https://github.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt/blob/master/LICENSE</PackageLicenseUrl>
<Version>1.0.0-beta3</Version>
<Version>1.0.0-beta4</Version>
<PackageTags>azure functions mqtt webjobs trigger binding function webjob</PackageTags>
<AssemblyName>CaseOnline.Azure.WebJobs.Extensions.Mqtt</AssemblyName>
<RootNamespace>CaseOnline.Azure.WebJobs.Extensions.Mqtt</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public void Initialize(ExtensionConfigContext context)
context.Trace.Info("MqttExtensionConfigProvider.Initialize() called!");

var logger = context.Config.LoggerFactory.CreateLogger(LogCategories.CreateTriggerCategory("Mqtt"));
logger.LogWarning("Logger not working?");

_nameResolver = context.Config.GetService<INameResolver>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ public void Execute(object stateInfo)

private void ManagedMqttClientDisconnected(object sender, MqttClientDisconnectedEventArgs e)
{
_traceWriter.Error($"MqttListener._client_Disconnected, was :{e.ClientWasConnected} for {Descriptor}", e.Exception);
_traceWriter.Error($"MqttListener Disconnected, previous connectivity state '{e.ClientWasConnected}' for {Descriptor}", e.Exception);
}

private void ManagedMqttClientConnected(object sender, MqttClientConnectedEventArgs e)
{
_traceWriter.Info($"MqttListener._client_Connected {e.IsSessionPresent} for {Descriptor}");
_traceWriter.Info($"MqttListener Connected {e.IsSessionPresent} for {Descriptor}");
}

private void ManagedMqttClientApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs e)
{
_traceWriter.Info("Mqtt client receiving message for {descriptor}");
_traceWriter.Info($"MqttListener receiving message for {Descriptor}");
InvokeJobFunction(e).Wait();
}

Expand Down

0 comments on commit 3f28cd0

Please sign in to comment.