├── .github
└── fabricbot.json
├── .gitignore
├── EventHubsExtension.sln
├── LICENSE.txt
├── NuGet.Config
├── README.md
├── SECURITY.md
├── release_notes.md
├── sign.snk
├── src.ruleset
├── src
└── Microsoft.Azure.WebJobs.Extensions.EventHubs
│ ├── Config
│ ├── EventHubExtensionConfigProvider.cs
│ ├── EventHubOptions.cs
│ ├── EventHubWebJobsBuilderExtensions.cs
│ └── InitialOffsetOptions.cs
│ ├── EventHubAttribute.cs
│ ├── EventHubTriggerAttribute.cs
│ ├── EventHubsWebJobsStartup.cs
│ ├── Extensions
│ └── SystemPropertiesCollectionExtensions.cs
│ ├── Listeners
│ ├── EventHubListener.cs
│ ├── EventHubsScaleMonitor.cs
│ └── EventHubsTriggerMetrics.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Triggers
│ ├── EventHubAsyncCollector.cs
│ ├── EventHubTriggerAttributeBindingProvider.cs
│ ├── EventHubTriggerInput.cs
│ └── EventHubTriggerInputBindingStrategy.cs
│ ├── Utility.cs
│ ├── WebJobs.Extensions.EventHubs.csproj
│ └── webjobs.png
├── stylecop.json
└── test
├── Microsoft.Azure.WebJobs.Extensions.EventHubs.Tests
├── EventHubApplicationInsightsTest.cs
├── EventHubAsyncCollectorTests.cs
├── EventHubConfigurationTests.cs
├── EventHubEndToEndTests.cs
├── EventHubListenerTests.cs
├── EventHubTests.cs
├── EventHubsScaleMonitorTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── PublicSurfaceTests.cs
└── WebJobs.Extensions.EventHubs.Tests.csproj
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
--------------------------------------------------------------------------------
/EventHubsExtension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2024
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebJobs.Extensions.EventHubs", "src\Microsoft.Azure.WebJobs.Extensions.EventHubs\WebJobs.Extensions.EventHubs.csproj", "{A2B3C676-3DF0-43B4-92A2-7E7DAA7BF439}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebJobs.Extensions.EventHubs.Tests", "test\Microsoft.Azure.WebJobs.Extensions.EventHubs.Tests\WebJobs.Extensions.EventHubs.Tests.csproj", "{D37637D5-7EF9-43CB-86BE-537473CD613B}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {A2B3C676-3DF0-43B4-92A2-7E7DAA7BF439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {A2B3C676-3DF0-43B4-92A2-7E7DAA7BF439}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {A2B3C676-3DF0-43B4-92A2-7E7DAA7BF439}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {A2B3C676-3DF0-43B4-92A2-7E7DAA7BF439}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {D37637D5-7EF9-43CB-86BE-537473CD613B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {D37637D5-7EF9-43CB-86BE-537473CD613B}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {D37637D5-7EF9-43CB-86BE-537473CD613B}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {D37637D5-7EF9-43CB-86BE-537473CD613B}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {43B8428A-8A26-45B1-A0D9-D33AD1F054CE}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) .NET Foundation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Event Hubs Extension for Azure Functions [Archived]
2 |
3 | This GitHub project has been archived. Ongoing development on this project can be found in https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs.
4 |
5 | This extension provides functionality for receiving Event Hubs messges in Azure Functions, allowing you to easily write functions that respond to any message published to Event Hubs.
6 |
7 | |Branch|Status|
8 | |---|---|
9 | |dev|[](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=18&branchName=dev)
10 |
11 | ## License
12 |
13 | This project is under the benevolent umbrella of the [.NET Foundation](http://www.dotnetfoundation.org/) and is licensed under [the MIT License](https://github.com/Azure/azure-webjobs-sdk/blob/master/LICENSE.txt)
14 |
15 | ## Contributing
16 |
17 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
18 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6 |
7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14 |
15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16 |
17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18 |
19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20 |
21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | * Full paths of source file(s) related to the manifestation of the issue
23 | * The location of the affected source code (tag/branch/commit or direct URL)
24 | * Any special configuration required to reproduce the issue
25 | * Step-by-step instructions to reproduce the issue
26 | * Proof-of-concept or exploit code (if possible)
27 | * Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40 |
41 |
42 |
--------------------------------------------------------------------------------
/release_notes.md:
--------------------------------------------------------------------------------
1 | ### Release notes
2 |
5 | #### Version 4.2.0
6 | - User configurable initial offset support [#79](https://github.com/Azure/azure-functions-eventhubs-extension/pull/79)
7 |
8 | #### Version 4.3.0
9 | - Adding explicit reference Microsoft.Azure.Amqp 2.4.11 [#99](https://github.com/Azure/azure-functions-eventhubs-extension/pull/99)
10 |
11 | #### Version 4.3.1
12 | - Stop Listener when disposed [#105](https://github.com/Azure/azure-functions-eventhubs-extension/pull/105)
13 | - Add listener details [#105](https://github.com/Azure/azure-functions-eventhubs-extension/pull/105)
14 |
--------------------------------------------------------------------------------
/sign.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure/azure-functions-eventhubs-extension/1cf1006f731f9015d5e1eadb4e6798b63d78313c/sign.snk
--------------------------------------------------------------------------------
/src.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/src/Microsoft.Azure.WebJobs.Extensions.EventHubs/Config/EventHubExtensionConfigProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Microsoft.Azure.EventHubs;
8 | using Microsoft.Azure.EventHubs.Processor;
9 | using Microsoft.Azure.WebJobs.Description;
10 | using Microsoft.Azure.WebJobs.Host.Bindings;
11 | using Microsoft.Azure.WebJobs.Host.Config;
12 | using Microsoft.Azure.WebJobs.Host.Configuration;
13 | using Microsoft.Azure.WebJobs.Logging;
14 | using Microsoft.Extensions.Configuration;
15 | using Microsoft.Extensions.Logging;
16 | using Microsoft.Extensions.Options;
17 | using Newtonsoft.Json;
18 |
19 | namespace Microsoft.Azure.WebJobs.EventHubs
20 | {
21 | [Extension("EventHubs", configurationSection: "EventHubs")]
22 | internal class EventHubExtensionConfigProvider : IExtensionConfigProvider
23 | {
24 | public IConfiguration _config;
25 | private readonly IOptions _options;
26 | private readonly ILoggerFactory _loggerFactory;
27 | private readonly IConverterManager _converterManager;
28 | private readonly INameResolver _nameResolver;
29 | private readonly IWebJobsExtensionConfiguration _configuration;
30 |
31 | public EventHubExtensionConfigProvider(IConfiguration config, IOptions options, ILoggerFactory loggerFactory,
32 | IConverterManager converterManager, INameResolver nameResolver, IWebJobsExtensionConfiguration configuration)
33 | {
34 | _config = config;
35 | _options = options;
36 | _loggerFactory = loggerFactory;
37 | _converterManager = converterManager;
38 | _nameResolver = nameResolver;
39 | _configuration = configuration;
40 | }
41 |
42 | internal Action ExceptionHandler { get; set; }
43 |
44 | private void ExceptionReceivedHandler(ExceptionReceivedEventArgs args)
45 | {
46 | ExceptionHandler?.Invoke(args);
47 | }
48 |
49 | public void Initialize(ExtensionConfigContext context)
50 | {
51 | if (context == null)
52 | {
53 | throw new ArgumentNullException(nameof(context));
54 | }
55 |
56 | _options.Value.EventProcessorOptions.SetExceptionHandler(ExceptionReceivedHandler);
57 | _configuration.ConfigurationSection.Bind(_options);
58 |
59 | context
60 | .AddConverter(ConvertString2EventData)
61 | .AddConverter(ConvertEventData2String)
62 | .AddConverter(ConvertBytes2EventData)
63 | .AddConverter(ConvertEventData2Bytes)
64 | .AddOpenConverter(ConvertPocoToEventData);
65 |
66 | // register our trigger binding provider
67 | var triggerBindingProvider = new EventHubTriggerAttributeBindingProvider(_config, _nameResolver, _converterManager, _options, _loggerFactory);
68 | context.AddBindingRule()
69 | .BindToTrigger(triggerBindingProvider);
70 |
71 | // register our binding provider
72 | context.AddBindingRule()
73 | .BindToCollector(BuildFromAttribute);
74 |
75 | context.AddBindingRule()
76 | .BindToInput(attribute =>
77 | {
78 | return _options.Value.GetEventHubClient(attribute.EventHubName, attribute.Connection);
79 | });
80 |
81 | ExceptionHandler = (e =>
82 | {
83 | LogExceptionReceivedEvent(e, _loggerFactory);
84 | });
85 | }
86 |
87 | internal static void LogExceptionReceivedEvent(ExceptionReceivedEventArgs e, ILoggerFactory loggerFactory)
88 | {
89 | var logger = loggerFactory?.CreateLogger(LogCategories.Executor);
90 | string message = $"EventProcessorHost error (Action='{e.Action}', HostName='{e.Hostname}', PartitionId='{e.PartitionId}').";
91 |
92 | Utility.LogException(e.Exception, message, logger);
93 | }
94 |
95 | private static LogLevel GetLogLevel(Exception ex)
96 | {
97 | if (ex is ReceiverDisconnectedException ||
98 | ex is LeaseLostException)
99 | {
100 | // For EventProcessorHost these exceptions can happen as part
101 | // of normal partition balancing across instances, so we want to
102 | // trace them, but not treat them as errors.
103 | return LogLevel.Information;
104 | }
105 |
106 | var ehex = ex as EventHubsException;
107 | if (!(ex is OperationCanceledException) && (ehex == null || !ehex.IsTransient))
108 | {
109 | // any non-transient exceptions or unknown exception types
110 | // we want to log as errors
111 | return LogLevel.Error;
112 | }
113 | else
114 | {
115 | // transient messaging errors we log as info so we have a record
116 | // of them, but we don't treat them as actual errors
117 | return LogLevel.Information;
118 | }
119 | }
120 |
121 | private IAsyncCollector BuildFromAttribute(EventHubAttribute attribute)
122 | {
123 | EventHubClient client = _options.Value.GetEventHubClient(attribute.EventHubName, attribute.Connection);
124 | return new EventHubAsyncCollector(client, _loggerFactory);
125 | }
126 |
127 | private static string ConvertEventData2String(EventData x)
128 | => Encoding.UTF8.GetString(ConvertEventData2Bytes(x));
129 |
130 | private static EventData ConvertBytes2EventData(byte[] input)
131 | => new EventData(input);
132 |
133 | private static byte[] ConvertEventData2Bytes(EventData input)
134 | => input.Body.Array;
135 |
136 | private static EventData ConvertString2EventData(string input)
137 | => ConvertBytes2EventData(Encoding.UTF8.GetBytes(input));
138 |
139 | private static Task