diff --git a/Microsoft.Azure.Devices.Edge.sln b/Microsoft.Azure.Devices.Edge.sln index 864c76b4d2..668a6a3a8e 100755 --- a/Microsoft.Azure.Devices.Edge.sln +++ b/Microsoft.Azure.Devices.Edge.sln @@ -93,19 +93,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1ABF19EE-768 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "binding", "binding", "{B8B03013-8D6E-4D4E-9914-33D55074DEC8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Devices.Edge.Functions.Binding", "edge-modules\functions\binding\src\Microsoft.Azure.Devices.Edge.Functions.Binding\Microsoft.Azure.Devices.Edge.Functions.Binding.csproj", "{63120FDB-92DD-4E02-B77A-E4B51999A0BB}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E}" ProjectSection(SolutionItems) = preProject edge-modules\functions\samples\host.json = edge-modules\functions\samples\host.json EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EdgeHubTrigger-CSharp", "EdgeHubTrigger-CSharp", "{AFA4A92F-62AA-4EA9-9AE2-70E7EC5FCB12}" - ProjectSection(SolutionItems) = preProject - edge-modules\functions\samples\EdgeHubTrigger-CSharp\function.json = edge-modules\functions\samples\EdgeHubTrigger-CSharp\function.json - edge-modules\functions\samples\EdgeHubTrigger-CSharp\run.csx = edge-modules\functions\samples\EdgeHubTrigger-CSharp\run.csx - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Devices.Edge.Storage", "edge-util\src\Microsoft.Azure.Devices.Edge.Storage\Microsoft.Azure.Devices.Edge.Storage.csproj", "{DB92F6C3-A611-40C5-B464-8F11A3EE1AC3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Devices.Edge.Storage.RocksDb", "edge-util\src\Microsoft.Azure.Devices.Edge.Storage.RocksDb\Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj", "{D6BFCE1F-0F53-43F1-8D2B-FC0FF8EEFA9C}" @@ -120,11 +112,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{64E95D7B-8541-4A88-A291-8BE3445FB8FF}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{80688705-AEFD-4297-907E-2B20DAFBB5D5}" - ProjectSection(SolutionItems) = preProject - edge-modules\functions\samples\bin\extensions.json = edge-modules\functions\samples\bin\extensions.json - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "linux", "linux", "{BCAA863C-8BC2-4FB1-9D9E-7BCADBCFC3A5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "amd64", "amd64", "{B5BB5CDE-E6C7-4896-A66E-17D81BDB9A31}" @@ -168,6 +155,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagesAnalyzer", "edge-mo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LeafDevice", "smoke\LeafDevice\LeafDevice.csproj", "{C5CBC493-96A4-4628-A952-8C7B9EEF1441}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.WebJobs.Extensions.EdgeHub", "edge-modules\functions\binding\src\Microsoft.Azure.WebJobs.Extensions.EdgeHub\Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj", "{0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EdgeHubTrigger-CSharp", "EdgeHubTrigger-CSharp", "{C3BDC9FA-B7D8-44F3-970F-D24281335F46}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeHubTriggerCSharp", "edge-modules\functions\samples\EdgeHubTrigger-Csharp\EdgeHubTriggerCSharp.csproj", "{B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{3A879277-5A61-4A6A-BB27-5281FA83B1D3}" + ProjectSection(SolutionItems) = preProject + edge-modules\functions\samples\bin\extensions.json = edge-modules\functions\samples\bin\extensions.json + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CodeCoverage|Any CPU = CodeCoverage|Any CPU @@ -325,12 +323,6 @@ Global {D67D382A-5F16-4AB2-8082-DBE62C33E5B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {D67D382A-5F16-4AB2-8082-DBE62C33E5B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {D67D382A-5F16-4AB2-8082-DBE62C33E5B1}.Release|Any CPU.Build.0 = Release|Any CPU - {63120FDB-92DD-4E02-B77A-E4B51999A0BB}.CodeCoverage|Any CPU.ActiveCfg = CodeCoverage|Any CPU - {63120FDB-92DD-4E02-B77A-E4B51999A0BB}.CodeCoverage|Any CPU.Build.0 = CodeCoverage|Any CPU - {63120FDB-92DD-4E02-B77A-E4B51999A0BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63120FDB-92DD-4E02-B77A-E4B51999A0BB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63120FDB-92DD-4E02-B77A-E4B51999A0BB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63120FDB-92DD-4E02-B77A-E4B51999A0BB}.Release|Any CPU.Build.0 = Release|Any CPU {DB92F6C3-A611-40C5-B464-8F11A3EE1AC3}.CodeCoverage|Any CPU.ActiveCfg = CodeCoverage|Any CPU {DB92F6C3-A611-40C5-B464-8F11A3EE1AC3}.CodeCoverage|Any CPU.Build.0 = CodeCoverage|Any CPU {DB92F6C3-A611-40C5-B464-8F11A3EE1AC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -415,6 +407,18 @@ Global {C5CBC493-96A4-4628-A952-8C7B9EEF1441}.Debug|Any CPU.Build.0 = Debug|Any CPU {C5CBC493-96A4-4628-A952-8C7B9EEF1441}.Release|Any CPU.ActiveCfg = Release|Any CPU {C5CBC493-96A4-4628-A952-8C7B9EEF1441}.Release|Any CPU.Build.0 = Release|Any CPU + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}.CodeCoverage|Any CPU.ActiveCfg = CodeCoverage|Any CPU + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}.CodeCoverage|Any CPU.Build.0 = CodeCoverage|Any CPU + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4}.Release|Any CPU.Build.0 = Release|Any CPU + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}.CodeCoverage|Any CPU.ActiveCfg = Debug|Any CPU + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}.CodeCoverage|Any CPU.Build.0 = Debug|Any CPU + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -454,14 +458,11 @@ Global {C4502187-81D7-4299-85C3-64AE241503E0} = {578D5330-2F72-44C6-9DB5-C93B3F42C473} {1ABF19EE-7689-4EE3-A099-16111A8F16F4} = {B8B03013-8D6E-4D4E-9914-33D55074DEC8} {B8B03013-8D6E-4D4E-9914-33D55074DEC8} = {C4502187-81D7-4299-85C3-64AE241503E0} - {63120FDB-92DD-4E02-B77A-E4B51999A0BB} = {1ABF19EE-7689-4EE3-A099-16111A8F16F4} {33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E} = {C4502187-81D7-4299-85C3-64AE241503E0} - {AFA4A92F-62AA-4EA9-9AE2-70E7EC5FCB12} = {33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E} {DB92F6C3-A611-40C5-B464-8F11A3EE1AC3} = {66964A75-04AC-4FDE-8505-E6CB2EF90BE8} {D6BFCE1F-0F53-43F1-8D2B-FC0FF8EEFA9C} = {66964A75-04AC-4FDE-8505-E6CB2EF90BE8} {3EB5B58A-5820-44E7-9558-917C105B940D} = {373FFF5E-E84C-4789-B768-676FFF51E7A6} {64E95D7B-8541-4A88-A291-8BE3445FB8FF} = {33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E} - {80688705-AEFD-4297-907E-2B20DAFBB5D5} = {33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E} {BCAA863C-8BC2-4FB1-9D9E-7BCADBCFC3A5} = {64E95D7B-8541-4A88-A291-8BE3445FB8FF} {B5BB5CDE-E6C7-4896-A66E-17D81BDB9A31} = {BCAA863C-8BC2-4FB1-9D9E-7BCADBCFC3A5} {31B0F93F-3E58-4C66-9DCC-24236EA81F16} = {BCAA863C-8BC2-4FB1-9D9E-7BCADBCFC3A5} @@ -478,6 +479,10 @@ Global {54771470-860C-4853-9318-6DB4EA76B595} = {578D5330-2F72-44C6-9DB5-C93B3F42C473} {047DC795-A159-4BFF-AC0F-4DCE51A79C2C} = {578D5330-2F72-44C6-9DB5-C93B3F42C473} {C5CBC493-96A4-4628-A952-8C7B9EEF1441} = {871A0862-7480-49C3-ACEB-9A60E9CE5B61} + {0D5C5996-7414-47D2-AF0F-C68E0E3F3AA4} = {1ABF19EE-7689-4EE3-A099-16111A8F16F4} + {C3BDC9FA-B7D8-44F3-970F-D24281335F46} = {33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E} + {B8D5312A-B37B-4FA3-8B80-2D1A93077DDF} = {C3BDC9FA-B7D8-44F3-970F-D24281335F46} + {3A879277-5A61-4A6A-BB27-5281FA83B1D3} = {33B7755E-D6F9-4F9B-86A8-5DFE9FEE674E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D71830F5-3AF5-46B4-8A9E-1DCE4F2253AC} diff --git a/edge-modules/functions/binding/docker/linux/amd64/Dockerfile b/edge-modules/functions/binding/docker/linux/amd64/Dockerfile deleted file mode 100644 index 57a6a738cb..0000000000 --- a/edge-modules/functions/binding/docker/linux/amd64/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM microsoft/azure-functions-dotnet-core2.0:2.0 - -WORKDIR /app - -COPY $EXE_DIR/ ./bindings - -CMD ["dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll"] \ No newline at end of file diff --git a/edge-modules/functions/binding/docker/linux/arm32v7/Dockerfile b/edge-modules/functions/binding/docker/linux/arm32v7/Dockerfile deleted file mode 100644 index 16afc21768..0000000000 --- a/edge-modules/functions/binding/docker/linux/arm32v7/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM microsoft/azure-functions-dotnet-core2.0:2.0-arm32v7 - -WORKDIR /app - -COPY $EXE_DIR/ ./bindings \ No newline at end of file diff --git a/edge-modules/functions/binding/docker/windows/amd64/Dockerfile b/edge-modules/functions/binding/docker/windows/amd64/Dockerfile deleted file mode 100644 index 90c178158d..0000000000 --- a/edge-modules/functions/binding/docker/windows/amd64/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -# escape=` - -FROM microsoft/azure-functions-dotnet-core2.0:2.0-nanoserver-1803 - -ARG EXE_DIR=. - -WORKDIR /app - -COPY $EXE_DIR/ ./bindings \ No newline at end of file diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubExtensionConfigProvider.cs b/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubExtensionConfigProvider.cs deleted file mode 100644 index d254f1cc6a..0000000000 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubExtensionConfigProvider.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -namespace Microsoft.Azure.Devices.Edge.Functions.Binding.Config -{ - using System; - using Microsoft.Azure.Devices.Client; - using Microsoft.Azure.Devices.Edge.Functions.Binding.Bindings; - using Microsoft.Azure.WebJobs.Host; - using Microsoft.Azure.WebJobs.Host.Config; - using Microsoft.Azure.WebJobs.Host.Triggers; - using Newtonsoft.Json; - - /// - /// Extension configuration provider used to register EdgeHub triggers and binders - /// - public class EdgeHubExtensionConfigProvider : IExtensionConfigProvider - { - public void Initialize(ExtensionConfigContext context) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var extensions = context.Config.GetService(); - - // register trigger binding provider - var triggerBindingProvider = new EdgeHubTriggerBindingProvider(); - extensions.RegisterExtension(triggerBindingProvider); - - extensions.RegisterBindingRules(); - FluentBindingRule rule = context.AddBindingRule(); - rule.BindToCollector(typeof(EdgeHubCollectorBuilder)); - - context.AddConverter(this.MessageConverter); - context.AddConverter(this.ConvertToMessage); - } - - Message ConvertToMessage(string str) - { - return JsonConvert.DeserializeObject(str); - } - - string MessageConverter(Message msg) - { - return JsonConvert.SerializeObject(msg); - } - } -} diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubHostConfigExtensions.cs b/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubHostConfigExtensions.cs deleted file mode 100644 index c44d0f1cbd..0000000000 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubHostConfigExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -namespace Microsoft.Azure.Devices.Edge.Functions.Binding.Config -{ - using System; - using Microsoft.Azure.WebJobs; - using Microsoft.Azure.WebJobs.Host; - using Microsoft.Azure.WebJobs.Host.Config; - - /// - /// Extension methods for EdgeHub integration - /// - public static class EdgeHubHostConfigExtensions - { - /// - /// Enables use of EdgeHub binding extensions - /// - /// The to configure. - public static void UseEdgeHub(this JobHostConfiguration config) - { - if (config == null) - { - throw new ArgumentNullException(nameof(config)); - } - - var extensions = config.GetService(); - - var extensionConfig = new EdgeHubExtensionConfigProvider(); - extensions.RegisterExtension(extensionConfig); - } - } -} diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/AsyncLock.cs b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/AsyncLock.cs new file mode 100644 index 0000000000..46042e393c --- /dev/null +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/AsyncLock.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft. All rights reserved. + +namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub +{ + // + // Code ported from http://blogs.msdn.com/b/pfxteam/archive/2012/02/12/10266988.aspx + // + using System; + using System.Threading; + using System.Threading.Tasks; + + sealed class AsyncLock : IDisposable + { + readonly Task releaser; + readonly SemaphoreSlim semaphore; + + public AsyncLock() + : this(1) + { + } + + public AsyncLock(int maximumConcurrency) + { + this.releaser = Task.FromResult(new Releaser(this)); + this.semaphore = new SemaphoreSlim(maximumConcurrency, maximumConcurrency); + } + + public Task LockAsync() => this.LockAsync(CancellationToken.None); + + public Task LockAsync(CancellationToken token) + { + Task wait = this.semaphore.WaitAsync(token); + return wait.Status == TaskStatus.RanToCompletion ? this.releaser : + wait.ContinueWith((_, state) => new Releaser((AsyncLock)state), + this, CancellationToken.None, + TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.Default); + } + + /// + public void Dispose() => this.semaphore.Dispose(); + + public struct Releaser : IDisposable + { + readonly AsyncLock toRelease; + int disposed; + + public Releaser(AsyncLock toRelease) + { + this.toRelease = toRelease ?? throw new ArgumentNullException(nameof(toRelease)); + this.disposed = 0; + } + + public void Dispose() + { + if (0 == Interlocked.Exchange(ref this.disposed, 1)) + { + this.toRelease.semaphore.Release(); + } + } + } + } +} diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubAsyncCollector.cs b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubAsyncCollector.cs similarity index 98% rename from edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubAsyncCollector.cs rename to edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubAsyncCollector.cs index bf95c8a075..02ec815946 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubAsyncCollector.cs +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubAsyncCollector.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Functions.Binding +namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub { using System; using System.Collections.Generic; diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubAttribute.cs b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubAttribute.cs similarity index 60% rename from edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubAttribute.cs rename to edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubAttribute.cs index b791fe3b90..b2daa1ccda 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubAttribute.cs +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubAttribute.cs @@ -1,15 +1,16 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Functions.Binding +namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub { using System; using Microsoft.Azure.WebJobs.Description; [Binding] + [AttributeUsage(AttributeTargets.Parameter)] public class EdgeHubAttribute : Attribute { public string OutputName { get; set; } public int BatchSize { get; set; } } -} \ No newline at end of file +} diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubTriggerAttribute.cs b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubTriggerAttribute.cs similarity index 93% rename from edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubTriggerAttribute.cs rename to edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubTriggerAttribute.cs index ca040009ff..6237f6e5ed 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubTriggerAttribute.cs +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubTriggerAttribute.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Functions.Binding +namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub { using System; using Microsoft.Azure.WebJobs.Description; diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubTriggerBindingProvider.cs b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubTriggerBindingProvider.cs similarity index 89% rename from edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubTriggerBindingProvider.cs rename to edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubTriggerBindingProvider.cs index ca4eb14a4f..795465eefc 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/EdgeHubTriggerBindingProvider.cs +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubTriggerBindingProvider.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Functions.Binding +namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub { using System; using System.Collections.Concurrent; @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Devices.Edge.Functions.Binding using System.Reflection; using System.Threading.Tasks; using Microsoft.Azure.Devices.Client; - using Microsoft.Azure.Devices.Edge.Functions.Binding.Bindings; using Microsoft.Azure.WebJobs.Host.Triggers; /// @@ -35,11 +34,6 @@ namespace Microsoft.Azure.Devices.Edge.Functions.Binding return null; } - if (parameter.ParameterType != typeof(Message) && parameter.ParameterType != typeof(string)) - { - throw new InvalidOperationException($"Can't bind EdgeHubTriggerAttribute to type '{parameter.ParameterType}'."); - } - await this.TrySetEventDefaultHandlerAsync().ConfigureAwait(false); var messageProcessor = new EdgeHubMessageProcessor(); diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubWebJobsStartup.cs b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubWebJobsStartup.cs new file mode 100644 index 0000000000..28d579e622 --- /dev/null +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubWebJobsStartup.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft. All rights reserved. + +using Microsoft.Azure.WebJobs.Extensions.EdgeHub; +using Microsoft.Azure.WebJobs.Hosting; + +[assembly: WebJobsStartup(typeof(EdgeHubWebJobsStartup))] + +namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub +{ + using Microsoft.Azure.WebJobs.Extensions.EdgeHub.Config; + using Microsoft.Azure.WebJobs.Hosting; + + public class EdgeHubWebJobsStartup : IWebJobsStartup + { + public void Configure(IWebJobsBuilder builder) => builder.AddEdge(); + } +} diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/Microsoft.Azure.Devices.Edge.Functions.Binding.csproj b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj similarity index 54% rename from edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/Microsoft.Azure.Devices.Edge.Functions.Binding.csproj rename to edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj index c13c70e3b6..3570cc00fa 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.Devices.Edge.Functions.Binding/Microsoft.Azure.Devices.Edge.Functions.Binding.csproj +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj @@ -1,11 +1,25 @@ - + netstandard2.0 - Microsoft.Azure.Devices.Edge.Functions.BindingExtension + Microsoft.Azure.WebJobs.Extensions.EdgeHub True Debug;Release;CodeCoverage true + 1.0.0-beta-004 + + + + 1.0.0-beta-004 + Microsoft Azure Edge Function extension + Microsoft + true + https://github.com/Azure/iotedge/blob/master/LICENSE + This package contains binding extensions for IoTEdge. + http://go.microsoft.com/fwlink/?LinkID=288890 + https://github.com/Azure/iotedge + © Microsoft Corporation. All rights reserved. + IoT Microsoft Azure IoTEdge Functions