Skip to content

Commit 9b934bb

Browse files
authored
Add new extensions, and samples (#139)
The extensions added here are -- EventGrid, ServiceBus, EventHubs, SignalRService, RabbitMQ, Kafka, Warmup and Table (from storage). This commit also adds samples using each of these new bindings.
1 parent e4096d8 commit 9b934bb

File tree

63 files changed

+1904
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1904
-43
lines changed

DotNetWorker.sln

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Timer", "
4747
EndProject
4848
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.CosmosDB", "extensions\Worker.Extensions.CosmosDB\Worker.Extensions.CosmosDB.csproj", "{37F71B56-1FC7-4BEC-9AB4-FF57C6BF2882}"
4949
EndProject
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.EventGrid", "extensions\Worker.Extensions.EventGrid\Worker.Extensions.EventGrid.csproj", "{9C305047-0B81-4DA1-98D4-BC8B391A2297}"
51+
EndProject
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.ServiceBus", "extensions\Worker.Extensions.ServiceBus\Worker.Extensions.ServiceBus.csproj", "{660B4D9D-081A-4DCA-BD7A-E196F4529BFD}"
53+
EndProject
54+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.EventHubs", "extensions\Worker.Extensions.EventHubs\Worker.Extensions.EventHubs.csproj", "{4A5770BE-6BB7-448F-A818-DD1450F8CBDC}"
55+
EndProject
56+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.RabbitMQ", "extensions\Worker.Extensions.RabbitMQ\Worker.Extensions.RabbitMQ.csproj", "{55652CF7-E58B-4564-A76B-D49DC71878DC}"
57+
EndProject
58+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.SignalRService", "extensions\Worker.Extensions.SignalRService\Worker.Extensions.SignalRService.csproj", "{A9802FBA-CF59-462B-88A0-1D7D0D19C748}"
59+
EndProject
60+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Warmup", "extensions\Worker.Extensions.Warmup\Worker.Extensions.Warmup.csproj", "{BDA0BCB4-BD26-4B10-B865-87082F290B38}"
61+
EndProject
62+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Kafka", "extensions\Worker.Extensions.Kafka\Worker.Extensions.Kafka.csproj", "{F63A63A9-FE09-4225-A293-6A58F9C1E520}"
63+
EndProject
64+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{9B3D2089-8166-4E0E-9F1B-8A242D9807F1}"
65+
EndProject
5066
Global
5167
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5268
Debug|Any CPU = Debug|Any CPU
@@ -105,6 +121,38 @@ Global
105121
{37F71B56-1FC7-4BEC-9AB4-FF57C6BF2882}.Debug|Any CPU.Build.0 = Debug|Any CPU
106122
{37F71B56-1FC7-4BEC-9AB4-FF57C6BF2882}.Release|Any CPU.ActiveCfg = Release|Any CPU
107123
{37F71B56-1FC7-4BEC-9AB4-FF57C6BF2882}.Release|Any CPU.Build.0 = Release|Any CPU
124+
{9C305047-0B81-4DA1-98D4-BC8B391A2297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
125+
{9C305047-0B81-4DA1-98D4-BC8B391A2297}.Debug|Any CPU.Build.0 = Debug|Any CPU
126+
{9C305047-0B81-4DA1-98D4-BC8B391A2297}.Release|Any CPU.ActiveCfg = Release|Any CPU
127+
{9C305047-0B81-4DA1-98D4-BC8B391A2297}.Release|Any CPU.Build.0 = Release|Any CPU
128+
{660B4D9D-081A-4DCA-BD7A-E196F4529BFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
129+
{660B4D9D-081A-4DCA-BD7A-E196F4529BFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
130+
{660B4D9D-081A-4DCA-BD7A-E196F4529BFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
131+
{660B4D9D-081A-4DCA-BD7A-E196F4529BFD}.Release|Any CPU.Build.0 = Release|Any CPU
132+
{4A5770BE-6BB7-448F-A818-DD1450F8CBDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
133+
{4A5770BE-6BB7-448F-A818-DD1450F8CBDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
134+
{4A5770BE-6BB7-448F-A818-DD1450F8CBDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
135+
{4A5770BE-6BB7-448F-A818-DD1450F8CBDC}.Release|Any CPU.Build.0 = Release|Any CPU
136+
{55652CF7-E58B-4564-A76B-D49DC71878DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{55652CF7-E58B-4564-A76B-D49DC71878DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{55652CF7-E58B-4564-A76B-D49DC71878DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
139+
{55652CF7-E58B-4564-A76B-D49DC71878DC}.Release|Any CPU.Build.0 = Release|Any CPU
140+
{A9802FBA-CF59-462B-88A0-1D7D0D19C748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
141+
{A9802FBA-CF59-462B-88A0-1D7D0D19C748}.Debug|Any CPU.Build.0 = Debug|Any CPU
142+
{A9802FBA-CF59-462B-88A0-1D7D0D19C748}.Release|Any CPU.ActiveCfg = Release|Any CPU
143+
{A9802FBA-CF59-462B-88A0-1D7D0D19C748}.Release|Any CPU.Build.0 = Release|Any CPU
144+
{BDA0BCB4-BD26-4B10-B865-87082F290B38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
145+
{BDA0BCB4-BD26-4B10-B865-87082F290B38}.Debug|Any CPU.Build.0 = Debug|Any CPU
146+
{BDA0BCB4-BD26-4B10-B865-87082F290B38}.Release|Any CPU.ActiveCfg = Release|Any CPU
147+
{BDA0BCB4-BD26-4B10-B865-87082F290B38}.Release|Any CPU.Build.0 = Release|Any CPU
148+
{F63A63A9-FE09-4225-A293-6A58F9C1E520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
149+
{F63A63A9-FE09-4225-A293-6A58F9C1E520}.Debug|Any CPU.Build.0 = Debug|Any CPU
150+
{F63A63A9-FE09-4225-A293-6A58F9C1E520}.Release|Any CPU.ActiveCfg = Release|Any CPU
151+
{F63A63A9-FE09-4225-A293-6A58F9C1E520}.Release|Any CPU.Build.0 = Release|Any CPU
152+
{9B3D2089-8166-4E0E-9F1B-8A242D9807F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
153+
{9B3D2089-8166-4E0E-9F1B-8A242D9807F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
154+
{9B3D2089-8166-4E0E-9F1B-8A242D9807F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
155+
{9B3D2089-8166-4E0E-9F1B-8A242D9807F1}.Release|Any CPU.Build.0 = Release|Any CPU
108156
EndGlobalSection
109157
GlobalSection(SolutionProperties) = preSolution
110158
HideSolutionNode = FALSE
@@ -122,6 +170,14 @@ Global
122170
{D6EAB0C1-491C-4723-B1F3-B6F5461CD359} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
123171
{4DBEC557-E5CC-41E9-9319-BC02615CF228} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
124172
{37F71B56-1FC7-4BEC-9AB4-FF57C6BF2882} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
173+
{9C305047-0B81-4DA1-98D4-BC8B391A2297} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
174+
{660B4D9D-081A-4DCA-BD7A-E196F4529BFD} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
175+
{4A5770BE-6BB7-448F-A818-DD1450F8CBDC} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
176+
{55652CF7-E58B-4564-A76B-D49DC71878DC} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
177+
{A9802FBA-CF59-462B-88A0-1D7D0D19C748} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
178+
{BDA0BCB4-BD26-4B10-B865-87082F290B38} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
179+
{F63A63A9-FE09-4225-A293-6A58F9C1E520} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
180+
{9B3D2089-8166-4E0E-9F1B-8A242D9807F1} = {9D6603BD-7EA2-4D11-A69C-0D9E01317FD6}
125181
EndGlobalSection
126182
GlobalSection(ExtensibilityGlobals) = postSolution
127183
SolutionGuid = {497D2ED4-A13E-4BCA-8D29-F30CA7D0EA4A}

build/Common.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
<Authors>Microsoft</Authors>
1717
<Company>Microsoft</Company>
1818
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
19-
<RepositoryUrl>https://github.com/Azure/azure-functions-dotnet-worker-preview</RepositoryUrl>
19+
<RepositoryUrl>https://github.com/Azure/azure-functions-dotnet-worker</RepositoryUrl>
2020
<RepositoryType>git</RepositoryType>
2121
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
2222
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=2028464</PackageLicenseUrl>
23-
<PackageProjectUrl>https://github.com/Azure/azure-functions-dotnet-worker-preview</PackageProjectUrl>
23+
<PackageProjectUrl>https://github.com/Azure/azure-functions-dotnet-worker</PackageProjectUrl>
2424
<Nullable>enable</Nullable>
2525
<DebugType>embedded</DebugType>
2626

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extensions.CosmosDB
7+
{
8+
public sealed class CosmosDBInputAttribute : InputBindingAttribute
9+
{
10+
/// <summary>
11+
/// Constructs a new instance.
12+
/// </summary>
13+
/// <param name="databaseName">The CosmosDB database name.</param>
14+
/// <param name="collectionName">The CosmosDB collection name.</param>
15+
public CosmosDBInputAttribute(string databaseName, string collectionName)
16+
{
17+
DatabaseName = databaseName;
18+
CollectionName = collectionName;
19+
}
20+
21+
/// <summary>
22+
/// The name of the database to which the parameter applies.
23+
/// May include binding parameters.
24+
/// </summary>
25+
public string DatabaseName { get; private set; }
26+
27+
/// <summary>
28+
/// The name of the collection to which the parameter applies.
29+
/// May include binding parameters.
30+
/// </summary>
31+
public string CollectionName { get; private set; }
32+
33+
/// <summary>
34+
/// Optional. A string value indicating the app setting to use as the CosmosDB connection string, if different
35+
/// than the one specified in the <see cref="CosmosDBOptions"/>.
36+
/// </summary>
37+
public string? ConnectionStringSetting { get; set; }
38+
39+
/// <summary>
40+
/// Optional. The Id of the document to retrieve from the collection.
41+
/// May include binding parameters.
42+
/// </summary>
43+
public string? Id { get; set; }
44+
45+
/// <summary>
46+
/// Optional.
47+
/// When specified on an output binding and <see cref="CreateIfNotExists"/> is true, defines the partition key
48+
/// path for the created collection.
49+
/// When specified on an input binding, specifies the partition key value for the lookup.
50+
/// May include binding parameters.
51+
/// </summary>
52+
public string? PartitionKey { get; set; }
53+
54+
/// <summary>
55+
/// Optional.
56+
/// When specified on an input binding using an <see cref="System.Collections.Generic.IEnumerable{T}"/>, defines the query to run against the collection.
57+
/// May include binding parameters.
58+
/// </summary>
59+
public string? SqlQuery { get; set; }
60+
61+
/// <summary>
62+
/// Optional.
63+
/// Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
64+
/// Values should be comma-separated.
65+
/// </summary>
66+
/// <example>
67+
/// PreferredLocations = "East US,South Central US,North Europe"
68+
/// </example>
69+
public string? PreferredLocations { get; set; }
70+
}
71+
}

extensions/Worker.Extensions.CosmosDB/CosmosDBOutputAttribute.cs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
55

66
namespace Microsoft.Azure.Functions.Worker.Extensions.CosmosDB
77
{
8-
public class CosmosDBOutputAttribute : OutputBindingAttribute
8+
public sealed class CosmosDBOutputAttribute : OutputBindingAttribute
99
{
1010
/// <summary>
1111
/// Constructs a new instance.
@@ -43,12 +43,6 @@ public CosmosDBOutputAttribute(string name, string databaseName, string collecti
4343
/// </summary>
4444
public string? ConnectionStringSetting { get; set; }
4545

46-
/// <summary>
47-
/// Optional. The Id of the document to retrieve from the collection.
48-
/// May include binding parameters.
49-
/// </summary>
50-
public string? Id { get; set; }
51-
5246
/// <summary>
5347
/// Optional.
5448
/// When specified on an output binding and <see cref="CreateIfNotExists"/> is true, defines the partition key
@@ -65,31 +59,12 @@ public CosmosDBOutputAttribute(string name, string databaseName, string collecti
6559
/// </summary>
6660
public int CollectionThroughput { get; set; }
6761

68-
/// <summary>
69-
/// Optional.
70-
/// When specified on an input binding using an <see cref="System.Collections.Generic.IEnumerable{T}"/>, defines the query to run against the collection.
71-
/// May include binding parameters.
72-
/// </summary>
73-
public string? SqlQuery { get; set; }
74-
7562
/// <summary>
7663
/// Optional.
7764
/// Enable to use with Multi Master accounts.
7865
/// </summary>
7966
public bool UseMultipleWriteLocations { get; set; }
8067

81-
/// <summary>
82-
/// Optional.
83-
/// Enables the use of JsonConvert.DefaultSettings in the monitored Azure Cosmos DB collection.
84-
/// <remarks>
85-
/// This setting only applies to the monitored collection and the consumer to setup the serialization used in the monitored collection.
86-
/// The JsonConvert.DefaultSettings must be set during the initialization process.
87-
/// This is achieved by deriving a class from <see cref="CosmosDBWebJobsStartup"/> and adding a <see cref="WebJobsStartupAttribute"/>
88-
/// to the assembly that specifies the derived class
89-
/// </remarks>
90-
/// </summary>
91-
public bool UseDefaultJsonSerialization { get; set; }
92-
9368
/// <summary>
9469
/// Optional.
9570
/// Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.

extensions/Worker.Extensions.CosmosDB/Worker.Extensions.CosmosDB.csproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Import Project="..\..\build\Common.props" />
43
<PropertyGroup>
54
<TargetFramework>netstandard2.0</TargetFramework>
65
<LangVersion>preview</LangVersion>
76
<AssemblyName>Microsoft.Azure.Functions.Worker.Extensions.CosmosDB</AssemblyName>
87
<RootNamespace>Microsoft.Azure.Functions.Worker.Extensions.CosmosDB</RootNamespace>
98
<SignAssembly>true</SignAssembly>
109
<AssemblyOriginatorKeyFile>..\..\key.snk</AssemblyOriginatorKeyFile>
10+
<Version>3.0.9-preview1</Version>
11+
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>
12+
<InformationalVersion>$(Version) Commit hash: $(CommitHash)</InformationalVersion>
13+
<Authors>Microsoft</Authors>
14+
<Company>Microsoft</Company>
15+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
16+
<RepositoryUrl>https://github.com/Azure/azure-functions-dotnet-worker</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
19+
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=2028464</PackageLicenseUrl>
20+
<PackageProjectUrl>https://github.com/Azure/azure-functions-dotnet-worker</PackageProjectUrl>
21+
<Nullable>enable</Nullable>
22+
<DebugType>embedded</DebugType>
1123
</PropertyGroup>
1224

1325
<ItemGroup>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extensions.EventGrid
7+
{
8+
public sealed class EventGridOutputAttribute : OutputBindingAttribute
9+
{
10+
/// <summary>
11+
/// Initialize a new instance of the <see cref="EventGridOutputAttribute"/>
12+
/// </summary>
13+
/// <param name="name">The name of the output binding property to bind.</param>
14+
public EventGridOutputAttribute(string name) : base(name)
15+
{
16+
}
17+
18+
/// <summary>Gets or sets the topic events endpoint URI. Eg: https://topic1.westus2-1.eventgrid.azure.net/api/events
19+
/// This is found in the Event Grid Topic's definition. You can find information on getting the Url for a topic here: https://docs.microsoft.com/en-us/azure/event-grid/custom-event-quickstart#send-an-event-to-your-topic
20+
/// </summary>
21+
public string? TopicEndpointUri { get; set; }
22+
23+
/// <summary>Gets or sets the Topic Key setting. You can find information on getting the Key for a topic here: https://docs.microsoft.com/en-us/azure/event-grid/custom-event-quickstart#send-an-event-to-your-topic </summary>
24+
public string? TopicKeySetting { get; set; }
25+
}
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extensions.EventGrid
7+
{
8+
public sealed class EventGridTriggerAttribute : TriggerBindingAttribute
9+
{
10+
}
11+
}

extensions/Worker.Extensions.Timer/Properties/AssemblyInfo.cs renamed to extensions/Worker.Extensions.EventGrid/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
55

6-
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions", "4.0.1")]
6+
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.EventGrid", "2.1.0")]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<LangVersion>preview</LangVersion>
6+
<AssemblyName>Microsoft.Azure.Functions.Worker.Extensions.EventGrid</AssemblyName>
7+
<RootNamespace>Microsoft.Azure.Functions.Worker.Extensions.EventGrid</RootNamespace>
8+
<SignAssembly>true</SignAssembly>
9+
<AssemblyOriginatorKeyFile>..\..\key.snk</AssemblyOriginatorKeyFile>
10+
<Version>2.1.0-preview1</Version>
11+
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>
12+
<InformationalVersion>$(Version) Commit hash: $(CommitHash)</InformationalVersion>
13+
<Authors>Microsoft</Authors>
14+
<Company>Microsoft</Company>
15+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
16+
<RepositoryUrl>https://github.com/Azure/azure-functions-dotnet-worker</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
19+
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=2028464</PackageLicenseUrl>
20+
<PackageProjectUrl>https://github.com/Azure/azure-functions-dotnet-worker</PackageProjectUrl>
21+
<Nullable>enable</Nullable>
22+
<DebugType>embedded</DebugType>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<ProjectReference Include="..\Worker.Extensions.Abstractions\Worker.Extensions.Abstractions.csproj" />
27+
</ItemGroup>
28+
29+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extensions.EventHubs
7+
{
8+
public sealed class EventHubOutputAttribute : OutputBindingAttribute
9+
{
10+
/// <summary>
11+
/// Initialize a new instance of the <see cref="EventHubOutputAttribute"/>
12+
/// </summary>
13+
/// <param name="name">The name of the output binding property to bind.</param>
14+
/// <param name="eventHubName">Name of the event hub </param>
15+
public EventHubOutputAttribute(string name, string eventHubName) : base(name)
16+
{
17+
EventHubName = eventHubName;
18+
}
19+
20+
/// <summary>
21+
/// The name of the event hub.
22+
/// </summary>
23+
public string EventHubName { get; private set; }
24+
25+
/// <summary>
26+
/// Gets or sets the optional connection string name that contains the Event Hub connection string. If missing, tries to use a registered event hub sender.
27+
/// </summary>
28+
public string? Connection { get; set; }
29+
}
30+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
5+
6+
namespace Microsoft.Azure.Functions.Worker.Extensions.EventHubs
7+
{
8+
public sealed class EventHubTriggerAttribute : TriggerBindingAttribute
9+
{
10+
/// <summary>
11+
/// Create an instance of this attribute.
12+
/// </summary>
13+
/// <param name="eventHubName">Event hub to listen on for messages. </param>
14+
public EventHubTriggerAttribute(string eventHubName)
15+
{
16+
EventHubName = eventHubName;
17+
}
18+
19+
/// <summary>
20+
/// Name of the event hub.
21+
/// </summary>
22+
public string EventHubName { get; private set; }
23+
24+
/// <summary>
25+
/// Optional Name of the consumer group. If missing, then use the default name, "$Default"
26+
/// </summary>
27+
public string? ConsumerGroup { get; set; }
28+
29+
/// <summary>
30+
/// Gets or sets the optional app setting name that contains the Event Hub connection string. If missing, tries to use a registered event hub receiver.
31+
/// </summary>
32+
public string? Connection { get; set; }
33+
}
34+
}

0 commit comments

Comments
 (0)