azure / azure-functions-iothub-extension Goto Github PK
View Code? Open in Web Editor NEWIOT Hub Extension for Azure Functions
License: MIT License
IOT Hub Extension for Azure Functions
License: MIT License
I am trying to read all the messages arriving at IoT Hub and then push it to cosmosDb. but i wish to use version 2 [core].
There are important files that Microsoft projects should all have that are not present in this repository. A pull request has been opened to add the missing file(s). When the pr is merged this issue will be closed automatically.
Microsoft teams can learn more about this effort and share feedback within the open source guidance available internally.
This repo should be update with azure function 3.x and have C# Class Library sample also. I can't any information anywhere on the internet.
Hey guys,
Thanks for putting this together!
I started following the instructions and there are a few steps that are unclear from the README. Could you clarify?
To run, do the following:
- Zip extension .dll files and put them in Function's library via Advanced tools (Kudu)
I have done this, but I am not sure they are in the right place. The only place that I am able to upload with .dll files is directly into the /wwwroot
folder. I tried uploading directly to my function (C2D2), but it would not allow me to upload directly to that folder. My folder is called DLLs
.
- Add the path where the extension lives to appsetting using AzureWebJobs_ExtensionsPath as key
Given the above, I'm not sure the correct path. I have tried a few different iterations, namely /DLLs
, /wwwroot/DLLs
, D:/DLLs
, etc. I receive the following error message:
The function runtime is unable to start. mscorlib: Could not find a part of the path 'D:\DLLs'.
Hey guys,
Running into the following error. Not sure what is wrong with my bindings. Running in the portal. Any ideas?
[Error] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.C2D2'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'cloudToDevice' to type ICollector. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
My function.json
:
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"direction": "in",
"path": "temp_humidity",
"connection": "razzpi_events_IOTHUB",
"consumerGroup": "secondconsumergroup"
},
{
"type": "ioTCloudToDevice",
"name": "cloudToDevice",
"direction": "out",
"connection": "razzpi_events_IOTHUB"
}
],
"disabled": false
}
and run.csx
:
#r "Newtonsoft.Json"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
/* Sending D2C messages to C2D */
public static void Run(string myEventHubMessage, ICollector<string> cloudToDevice, ICollector<string> setDeviceTwin, TraceWriter log)
{
// myEventHubMessage = D2C message
log.Info($"C# Event Hub trigger function processed a message: {myEventHubMessage}");
test
var msgJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(myEventHubMessage);
var c2dItem = new
{
DeviceId = msgJson["DeviceId"],
MessageId = msgJson["MessageId"],
Message = "CLOUD " + msgJson["Message"]
};
var setDTItem = new
{
DeviceId = "receiverCarol",
UpdateId = msgJson["MessageId"],
Patch = new
{
properties = new
{
desired = new
{
telemetryConfig = new
{
configId = Guid.NewGuid().ToString()
}
}
}
}
};
try {
cloudToDevice.Add(JsonConvert.SerializeObject(c2dItem));
}
catch(Exception e) {
log.Error("Exception caught for c2dItem method: ", e);
log.Info("failed to add to Dave");
}
}
Have these been shipped as Nuget Packages? If so, consider this an issue requesting an update to README.md to include the Install-Package
commands to include them in a .Net Function. If not, consider this an issue to create & ship nuget packages for this extension ๐
Hi,
I am getting below error in my Azure function for C2D code. I have uploaded all the extension DLLs in my Function directory.
Microsoft.Azure.WebJobs.Script.Description.CompilationServiceException : C# compilation service error: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) ---> System.IO.FileLoadException : The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly,Boolean forIntrospection,Boolean raiseResolveEvent)
at System.Reflection.AssemblyName..ctor(String assemblyName)
at Microsoft.Azure.WebJobs.Host.JobHostMetadataProvider.TryResolveAssembly(String assemblyName,Assembly& assembly)
at Microsoft.Azure.WebJobs.Script.Binding.GeneralScriptBindingProvider.TryResolveAssembly(String assemblyName,Assembly& assembly) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Binding\GeneralScriptBindingProvider.cs : 58
at Microsoft.Azure.WebJobs.Script.Description.ExtensionSharedAssemblyProvider.TryResolveAssembly(String assemblyName,Assembly& assembly) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\ExtensionSharedAssemblyProvider.cs : 34
at Microsoft.Azure.WebJobs.Script.Description.FunctionMetadataResolver.ResolveReference(String reference,String baseFilePath,MetadataReferenceProperties properties) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\FunctionMetadataResolver.cs : 172
at Microsoft.CodeAnalysis.CommonReferenceManager2.ResolveReferenceDirective(String reference,Location location,TCompilation compilation) at Microsoft.CodeAnalysis.CommonReferenceManager
2.GetCompilationReferences(TCompilation compilation,DiagnosticBag diagnostics,ImmutableArray1& references,IDictionary
2& boundReferenceDirectives,ImmutableArray1& referenceDirectiveLocations) at Microsoft.CodeAnalysis.CommonReferenceManager
2.ResolveMetadataReferences(TCompilation compilation,Dictionary2 assemblyReferencesBySimpleName,ImmutableArray
1& references,IDictionary2& boundReferenceDirectiveMap,ImmutableArray
1& boundReferenceDirectives,ImmutableArray1& assemblies,ImmutableArray
1& modules,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ReferenceManager.CreateAndSetSourceAssemblyFullBind(CSharpCompilation compilation)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ReferenceManager.CreateSourceAssemblyForCompilation(CSharpCompilation compilation)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonGetTypeByMetadataName(String metadataName)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.Initialize(Compilation compilation,CompilationWithAnalyzersOptions analysisOptions,CompilationData compilationData,Boolean categorizeDiagnostics,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.ComputeAnalyzerDiagnosticsWithoutStateTrackingAsync(CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalyzerDiagnosticsWithoutStateTrackingAsync(ImmutableArray1 analyzers,CancellationToken cancellationToken) at async Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalyzerDiagnosticsAsync(??) at async Microsoft.Azure.WebJobs.Script.Description.CSharpCompilation.EmitAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\Compilation\CSharp\CSharpCompilation.cs : 104 End of inner exception at async Microsoft.Azure.WebJobs.Script.Description.CSharpCompilation.EmitAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\Compilation\CSharp\CSharpCompilation.cs : 124 at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 317 at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader
1.GetFunctionTargetAsync[T](Int32 attemptCount) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionLoader.cs : 0
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetFunctionTargetAsync() at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 195
2018-07-26T09:25:17.878 [Info] Function loader reset. Failed compilation result will not be cached.
My Function.JSON looks like this:
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"direction": "in",
"path": "messages/events",
"connection": "IOTconnString",
"consumerGroup": "$Default"
},
{
"name": "cloudToDevice",
"type": "ioTCloudToDevice",
"direction": "out",
"connection": "IoTConnectionString"
}
],
"disabled": false
}
The documentation in this repo for the IoT extension for Functions is no longer accurate when a user pulls down the nupkg for the IoT extension. It causes unnecessary confusion and should be marked as deprecated in its readme, or removed from GitHub entirely.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.