diff --git a/EventGridBinding.sln b/EventGridBinding.sln
index 64d2d32..d918494 100644
--- a/EventGridBinding.sln
+++ b/EventGridBinding.sln
@@ -3,9 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventGridBinding", "EventGridBinding\EventGridBinding.csproj", "{828D7696-5D52-4AEB-8973-4382E9760094}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D0455F87-5E51-4AFD-ACF1-2F50A352F3D5}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventGridExtension", "EventGridExtension\EventGridExtension.csproj", "{D04DD2A7-EE6B-44C2-B615-DC380D8D2569}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventGridExtension", "src\EventGridExtension\EventGridExtension.csproj", "{D04DD2A7-EE6B-44C2-B615-DC380D8D2569}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B40A0AB6-1971-4DE9-954A-DD92AF1694CC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventGridBinding", "test\EventGridBinding\EventGridBinding.csproj", "{828D7696-5D52-4AEB-8973-4382E9760094}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -13,16 +17,20 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {828D7696-5D52-4AEB-8973-4382E9760094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {828D7696-5D52-4AEB-8973-4382E9760094}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {828D7696-5D52-4AEB-8973-4382E9760094}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {828D7696-5D52-4AEB-8973-4382E9760094}.Release|Any CPU.Build.0 = Release|Any CPU
{D04DD2A7-EE6B-44C2-B615-DC380D8D2569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D04DD2A7-EE6B-44C2-B615-DC380D8D2569}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D04DD2A7-EE6B-44C2-B615-DC380D8D2569}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D04DD2A7-EE6B-44C2-B615-DC380D8D2569}.Release|Any CPU.Build.0 = Release|Any CPU
+ {828D7696-5D52-4AEB-8973-4382E9760094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {828D7696-5D52-4AEB-8973-4382E9760094}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {828D7696-5D52-4AEB-8973-4382E9760094}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {828D7696-5D52-4AEB-8973-4382E9760094}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {D04DD2A7-EE6B-44C2-B615-DC380D8D2569} = {D0455F87-5E51-4AFD-ACF1-2F50A352F3D5}
+ {828D7696-5D52-4AEB-8973-4382E9760094} = {B40A0AB6-1971-4DE9-954A-DD92AF1694CC}
+ EndGlobalSection
EndGlobal
diff --git a/EventGridExtension/DefaultPublisher.cs b/src/EventGridExtension/DefaultPublisher.cs
similarity index 100%
rename from EventGridExtension/DefaultPublisher.cs
rename to src/EventGridExtension/DefaultPublisher.cs
diff --git a/EventGridExtension/EventGridExtension.csproj b/src/EventGridExtension/EventGridExtension.csproj
similarity index 92%
rename from EventGridExtension/EventGridExtension.csproj
rename to src/EventGridExtension/EventGridExtension.csproj
index 0c6d333..05f9306 100644
--- a/EventGridExtension/EventGridExtension.csproj
+++ b/src/EventGridExtension/EventGridExtension.csproj
@@ -33,15 +33,6 @@
..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll
-
- ..\packages\Microsoft.Azure.WebJobs.Core.2.1.0-beta1\lib\net45\Microsoft.Azure.WebJobs.dll
-
-
- ..\packages\Microsoft.Azure.WebJobs.Extensions.2.1.0-beta1\lib\net45\Microsoft.Azure.WebJobs.Extensions.dll
-
-
- ..\packages\Microsoft.Azure.WebJobs.2.1.0-beta1\lib\net45\Microsoft.Azure.WebJobs.Host.dll
-
..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll
@@ -145,10 +136,25 @@
+
+
+
+ {E6F59990-F3A1-469F-A9D8-6D529121D385}
+ WebJobs.Extensions
+
+
+ {0E095CB2-3030-49FF-966C-785F1A55F0C1}
+ WebJobs.Host
+
+
+ {E3F2B2C8-6B8D-4D6A-A3AE-98366C9F3B49}
+ WebJobs
+
+
\ No newline at end of file
diff --git a/src/EventGridExtension/EventGridExtension.previous.nugetreferenceswitcher b/src/EventGridExtension/EventGridExtension.previous.nugetreferenceswitcher
new file mode 100644
index 0000000..2bab1fc
--- /dev/null
+++ b/src/EventGridExtension/EventGridExtension.previous.nugetreferenceswitcher
@@ -0,0 +1,3 @@
+WebJobs D:/azure-webjobs-sdk/src/Microsoft.Azure.WebJobs/WebJobs.csproj ../packages/Microsoft.Azure.WebJobs.Core.2.1.0-beta1/lib/net45/Microsoft.Azure.WebJobs.dll
+WebJobs.Host D:/azure-webjobs-sdk/src/Microsoft.Azure.WebJobs.Host/WebJobs.Host.csproj ../packages/Microsoft.Azure.WebJobs.2.1.0-beta1/lib/net45/Microsoft.Azure.WebJobs.Host.dll
+WebJobs.Extensions D:/azure-webjobs-sdk-extensions/src/WebJobs.Extensions/WebJobs.Extensions.csproj ../packages/Microsoft.Azure.WebJobs.Extensions.2.1.0-beta1/lib/net45/Microsoft.Azure.WebJobs.Extensions.dll
diff --git a/EventGridExtension/EventGridExtensionConfig.cs b/src/EventGridExtension/EventGridExtensionConfig.cs
similarity index 94%
rename from EventGridExtension/EventGridExtensionConfig.cs
rename to src/EventGridExtension/EventGridExtensionConfig.cs
index 13284e9..f1275fa 100644
--- a/EventGridExtension/EventGridExtensionConfig.cs
+++ b/src/EventGridExtension/EventGridExtensionConfig.cs
@@ -14,6 +14,13 @@ namespace Microsoft.Azure.WebJobs
public class EventGridExtensionConfig : IExtensionConfigProvider,
IAsyncConverter
{
+ private bool _isTest = false;
+ public bool IsTest
+ {
+ get { return _isTest; }
+ set { _isTest = value; }
+ }
+
public void Initialize(ExtensionConfigContext context)
{
if (context == null)
diff --git a/EventGridExtension/EventGridJobHostConfigurationExtensions.cs b/src/EventGridExtension/EventGridJobHostConfigurationExtensions.cs
similarity index 94%
rename from EventGridExtension/EventGridJobHostConfigurationExtensions.cs
rename to src/EventGridExtension/EventGridJobHostConfigurationExtensions.cs
index 4cd6a51..1bee2f9 100644
--- a/EventGridExtension/EventGridJobHostConfigurationExtensions.cs
+++ b/src/EventGridExtension/EventGridJobHostConfigurationExtensions.cs
@@ -16,7 +16,7 @@ namespace Microsoft.Azure.WebJobs
// Register our extension configuration provider
// done by the function runtime
- config.RegisterExtensionConfigProvider(new EventGridExtensionConfig());
+ config.RegisterExtensionConfigProvider(new EventGridExtensionConfig() { IsTest = true });
}
}
}
diff --git a/src/EventGridExtension/EventGridListener.cs b/src/EventGridExtension/EventGridListener.cs
new file mode 100644
index 0000000..22a1942
--- /dev/null
+++ b/src/EventGridExtension/EventGridListener.cs
@@ -0,0 +1,46 @@
+using Microsoft.Azure.WebJobs.Host.Executors;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Microsoft.Azure.WebJobs
+{
+ public class EventGridListener : Microsoft.Azure.WebJobs.Host.Listeners.IListener
+ {
+ public ITriggeredFunctionExecutor Executor { private set; get; }
+
+ private EventGridExtensionConfig _listenersStore;
+ private readonly string _functionName;
+
+ public EventGridListener(ITriggeredFunctionExecutor executor, EventGridExtensionConfig listenersStore, string functionName)
+ {
+ _listenersStore = listenersStore;
+ _functionName = functionName;
+ Executor = executor;
+ }
+
+ public Task StartAsync(CancellationToken cancellationToken)
+ {
+ _listenersStore.AddListener(_functionName, this);
+ return Task.FromResult(true);
+ }
+
+ public Task StopAsync(CancellationToken cancellationToken)
+ {
+ // calling order stop -> cancel -> dispose
+ return Task.FromResult(true);
+ }
+
+ public void Dispose()
+ {
+ // TODO unsubscribe
+ }
+
+ public void Cancel()
+ {
+ // TODO cancel any outstanding tasks initiated by this listener
+ }
+ }
+}
diff --git a/EventGridExtension/EventGridTriggerAttribute.cs b/src/EventGridExtension/EventGridTriggerAttribute.cs
similarity index 100%
rename from EventGridExtension/EventGridTriggerAttribute.cs
rename to src/EventGridExtension/EventGridTriggerAttribute.cs
diff --git a/EventGridExtension/EventGridTriggerAttributeBindingProvider.cs b/src/EventGridExtension/EventGridTriggerAttributeBindingProvider.cs
similarity index 96%
rename from EventGridExtension/EventGridTriggerAttributeBindingProvider.cs
rename to src/EventGridExtension/EventGridTriggerAttributeBindingProvider.cs
index 70e6216..c9b58d3 100644
--- a/EventGridExtension/EventGridTriggerAttributeBindingProvider.cs
+++ b/src/EventGridExtension/EventGridTriggerAttributeBindingProvider.cs
@@ -102,6 +102,11 @@ namespace Microsoft.Azure.WebJobs
public Task CreateListenerAsync(ListenerFactoryContext context)
{
+ // listenersStore is of Type "EventGridExtensionConfig"
+ if (_listenersStore.IsTest)
+ {
+ return Task.FromResult(new TestListener(context.Executor));
+ }
return Task.FromResult(new EventGridListener(context.Executor, _listenersStore, _functionName));
}
diff --git a/EventGridExtension/EventGridevent.cs b/src/EventGridExtension/EventGridevent.cs
similarity index 100%
rename from EventGridExtension/EventGridevent.cs
rename to src/EventGridExtension/EventGridevent.cs
diff --git a/EventGridExtension/EventHubArchivePublisher.cs b/src/EventGridExtension/EventHubArchivePublisher.cs
similarity index 100%
rename from EventGridExtension/EventHubArchivePublisher.cs
rename to src/EventGridExtension/EventHubArchivePublisher.cs
diff --git a/EventGridExtension/IPublisher.cs b/src/EventGridExtension/IPublisher.cs
similarity index 100%
rename from EventGridExtension/IPublisher.cs
rename to src/EventGridExtension/IPublisher.cs
diff --git a/EventGridExtension/Properties/AssemblyInfo.cs b/src/EventGridExtension/Properties/AssemblyInfo.cs
similarity index 100%
rename from EventGridExtension/Properties/AssemblyInfo.cs
rename to src/EventGridExtension/Properties/AssemblyInfo.cs
diff --git a/EventGridExtension/EventGridListener.cs b/src/EventGridExtension/TestListener.cs
similarity index 71%
rename from EventGridExtension/EventGridListener.cs
rename to src/EventGridExtension/TestListener.cs
index 1ed22cf..0917dfc 100644
--- a/EventGridExtension/EventGridListener.cs
+++ b/src/EventGridExtension/TestListener.cs
@@ -7,10 +7,55 @@ using System.Threading.Tasks;
namespace Microsoft.Azure.WebJobs
{
- public class EventGridListener : Microsoft.Azure.WebJobs.Host.Listeners.IListener
+ public class TestListener : Microsoft.Azure.WebJobs.Host.Listeners.IListener
{
- // this only works for anonymous blob access
- private const string stringJson = @"[{
+ public ITriggeredFunctionExecutor Executor { private set; get; }
+
+ private System.Timers.Timer _timer;
+
+ public TestListener(ITriggeredFunctionExecutor executor)
+ {
+ Executor = executor;
+
+ // For this sample, we're using a timer to generate
+ // trigger events. You'll replace this with your event source.
+
+ _timer = new System.Timers.Timer(5 * 1000)
+ {
+ AutoReset = false
+ };
+ _timer.Elapsed += OnTimer;
+ }
+
+ public Task StartAsync(CancellationToken cancellationToken)
+ {
+ _timer.Start();
+ return Task.FromResult(true);
+ }
+
+ public Task StopAsync(CancellationToken cancellationToken)
+ {
+ _timer.Stop();
+ return Task.FromResult(true);
+ }
+
+ public void Dispose()
+ {
+ _timer.Dispose();
+
+ }
+
+ public void Cancel()
+ {
+ // TODO: cancel any outstanding tasks initiated by this listener
+ }
+
+
+ private void OnTimer(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ // invoke the function executor
+ // this is similar to code in ProcessAsync()
+ string stringJson = @"[{
'topic': '/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/canaryeh/providers/Microsoft.EventHub/namespaces/canaryeh',
'subject': 'eventhubs/test',
'eventType': 'captureFileCreated',
@@ -29,68 +74,6 @@ namespace Microsoft.Azure.WebJobs
},
'publishTime': '2017-07-14T23:10:29.5004788Z'
}]";
- public ITriggeredFunctionExecutor Executor { private set; get; }
-
- private System.Timers.Timer _timer;
- private EventGridExtensionConfig _listenersStore;
- private readonly string _functionName;
-
- public EventGridListener(ITriggeredFunctionExecutor executor, EventGridExtensionConfig listenersStore, string functionName)
- {
- _listenersStore = listenersStore;
- _functionName = functionName;
- Executor = executor;
-
- // For this sample, we're using a timer to generate
- // trigger events. You'll replace this with your event source.
- /*
- _timer = new System.Timers.Timer(5 * 1000)
- {
- AutoReset = false
- };
- _timer.Elapsed += OnTimer;
- */
- }
-
- public Task StartAsync(CancellationToken cancellationToken)
- {
- if (_timer != null)
- {
- _timer.Start();
- }
- _listenersStore.AddListener(_functionName, this);
- return Task.FromResult(true);
- }
-
- public Task StopAsync(CancellationToken cancellationToken)
- {
- if (_timer != null)
- {
- _timer.Stop();
- }
- // SHUN TODO: calling order stop -> cancel -> dispose
- return Task.FromResult(true);
- }
-
- public void Dispose()
- {
- // SHUN TODO unsubscribe
- if (_timer != null)
- {
- _timer.Dispose();
- }
- }
-
- public void Cancel()
- {
- // TODO: cancel any outstanding tasks initiated by this listener
- }
-
-
- private void OnTimer(object sender, System.Timers.ElapsedEventArgs e)
- {
- // invoke the function executor
-
List events = JsonConvert.DeserializeObject>(stringJson);
foreach (var param in events)
{
diff --git a/EventGridExtension/app.config b/src/EventGridExtension/app.config
similarity index 100%
rename from EventGridExtension/app.config
rename to src/EventGridExtension/app.config
diff --git a/EventGridExtension/packages.config b/src/EventGridExtension/packages.config
similarity index 100%
rename from EventGridExtension/packages.config
rename to src/EventGridExtension/packages.config
diff --git a/EventGridBinding/App.config b/test/EventGridBinding/App.config
similarity index 100%
rename from EventGridBinding/App.config
rename to test/EventGridBinding/App.config
diff --git a/EventGridBinding/ApplicationInsights.config b/test/EventGridBinding/ApplicationInsights.config
similarity index 100%
rename from EventGridBinding/ApplicationInsights.config
rename to test/EventGridBinding/ApplicationInsights.config
diff --git a/EventGridBinding/EventGridBinding.csproj b/test/EventGridBinding/EventGridBinding.csproj
similarity index 99%
rename from EventGridBinding/EventGridBinding.csproj
rename to test/EventGridBinding/EventGridBinding.csproj
index f5696a3..753f3da 100644
--- a/EventGridBinding/EventGridBinding.csproj
+++ b/test/EventGridBinding/EventGridBinding.csproj
@@ -144,7 +144,7 @@
-
+
{d04dd2a7-ee6b-44c2-b615-dc380d8d2569}
EventGridExtension
diff --git a/EventGridBinding/Function.cs b/test/EventGridBinding/Function.cs
similarity index 84%
rename from EventGridBinding/Function.cs
rename to test/EventGridBinding/Function.cs
index 329b9dc..5384ada 100644
--- a/EventGridBinding/Function.cs
+++ b/test/EventGridBinding/Function.cs
@@ -11,9 +11,9 @@ namespace EventGridBinding
Console.WriteLine(value);
}
- public static void testInputStream([EventGridTrigger("eventhubarchive")] Stream myBlob, string name)
+ public static void testInputStream([EventGridTrigger("eventhubarchive")] Stream myBlob, string blobTrigger)
{
- Console.WriteLine($"file name {name}");
+ Console.WriteLine($"file name {blobTrigger}");
var reader = new StreamReader(myBlob);
string line = null;
while (!string.IsNullOrEmpty(line = reader.ReadLine()))
diff --git a/EventGridBinding/Program.cs b/test/EventGridBinding/Program.cs
similarity index 100%
rename from EventGridBinding/Program.cs
rename to test/EventGridBinding/Program.cs
diff --git a/EventGridBinding/Properties/AssemblyInfo.cs b/test/EventGridBinding/Properties/AssemblyInfo.cs
similarity index 100%
rename from EventGridBinding/Properties/AssemblyInfo.cs
rename to test/EventGridBinding/Properties/AssemblyInfo.cs
diff --git a/EventGridBinding/packages.config b/test/EventGridBinding/packages.config
similarity index 100%
rename from EventGridBinding/packages.config
rename to test/EventGridBinding/packages.config