# Receive

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.AzureEventHub/tree/main/Frends.AzureEventHub.Receive>

{% tabs %}
{% tab title="Parameter: Consumer" %}

| Name                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AuthenticationMethod : `AuthenticationMethod` | <p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><p>Possible values:</p><ul><li><code>ConnectionString</code>:</li></ul><p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><ul><li><code>SASToken</code>:</li></ul><p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><ul><li><code>OAuth2</code>:</li></ul><p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><p><br>Default: <code>0</code><br>Example: <code>AuthenticationMethod.ConnectionString</code></p> |
| EventHubName : `String`                       | <p>Specifies the name of the Event Hub to connect to.</p><p><br>Default: <code>-</code><br>Example: <code>ExampleHub</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ConsumerGroup : `String`                      | <p>Specifies the name of the consumer group for reading events.</p><p>If left empty, the default consumer group will be used.</p><p><br>Default: <code>-</code><br>Example: <code>$Default</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 🗝ConnectionString : `String`                 | <p>Specifies the connection string for the Event Hub.</p><p>Required when using AuthenticationMethod.ConnectionString.</p><p><br>Default: <code>-</code><br>Example: <code>Endpoint=sb://NamespaceName.servicebus.windows.net/;SharedAccessKeyName=KeyName;SharedAccessKey=KeyValue</code></p>                                                                                                                                                                                                                                                                                                                                                                                                         |
| Namespace : `String`                          | <p>Specifies the fully qualified namespace of the Event Hub.</p><p>Required when using SAS Token or OAuth2 authentication methods.</p><p><br>Default: <code>-</code><br>Example: <code>{yournamespace}.servicebus.windows.net</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| 🗝SASToken : `String`                         | <p>Specifies the Shared Access Signature token for authentication.</p><p>Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration.</p><p><br>Default: <code>-</code><br>Example: <code>sv=2021-04-10\&se=2022-04-10T10%3A431Z\&sr=c\&sp=l\&sig=ZJg983RovE%2BZXI</code></p>                                                                                                                                                                                                                                                                                                                                                            |
| 🗝TenantId : `String`                         | <p>Specifies the Azure Active Directory tenant (directory) ID for OAuth2 authentication.</p><p><br>Default: <code>-</code><br>Example: <code>Y6b1hf2a-80e2-xyz2-qwer3h-3a7c3a8as4b7f</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 🗝ClientId : `String`                         | <p>Specifies the client (application) ID for OAuth2 authentication.</p><p><br>Default: <code>-</code><br>Example: <code>Y6b1hf2a-80e2-xyz2-qwer3h-3a7c3a8as4b7f</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 🗝ClientSecret : `String`                     | <p>Specifies the client secret generated for the App Registration used for OAuth2 authentication.</p><p><br>Default: <code>-</code><br>Example: <code>Password</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| MaximumWaitTime : `Double`                    | <p>Specifies the maximum wait time (in seconds) for an event to become available before emitting an empty event.</p><p>If set to 0, the processor will wait indefinitely for an event to become available.</p><p>Note: <code>Consumer.MaximumWaitTime</code> cannot exceed <code>Options.MaxRunTime</code> when <code>Options.MaxRunTime</code> is greater than 0.</p><p><br>Default: <code>0</code><br>Example: <code>0, 10 , 10.1</code></p>                                                                                                                                                                                                                                                         |
| {% endtab %}                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

{% tab title="Parameter: Checkpoint" %}

| Name                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AuthenticationMethod : `AuthenticationMethod` | <p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><p>Possible values:</p><ul><li><code>ConnectionString</code>:</li></ul><p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><ul><li><code>SASToken</code>:</li></ul><p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><ul><li><code>OAuth2</code>:</li></ul><p>Specifies the method used for authentication.</p><p>Default is AuthenticationMethod.ConnectionString.</p><p><br>Default: <code>0</code><br>Example: <code>AuthenticationMethod.ConnectionString</code></p> |
| ContainerName : `String`                      | <p>The name of the blob container.</p><p><br>Default: <code>-</code><br>Example: <code>examplecontainer</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| CreateContainer : `Boolean`                   | <p>If true, a new container is created under the specified account if it doesn’t exist.</p><p>Not supported when using SAS Token as an authentication method.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 🗝ConnectionString : `String`                 | <p>A connection string for the blob container.</p><p><br>Default: <code>-</code><br>Example: <code>DefaultEndpointsProtocol=https;AccountName=accountname;AccountKey=Pdlrxyz==;EndpointSuffix=core.windows.net</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| BlobContainerUri : `String`                   | <p>The URI of the blob container.</p><p>Required when using SAS Token or OAuth2 authentication method.</p><p><br>Default: <code>-</code><br>Example: <code>https\://{account\_name}.blob.core.windows.net/{container\_name}</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 🗝SASToken : `String`                         | <p>Shared access signature token.</p><p><br>Default: <code>-</code><br>Example: <code>sv=2021-04-10\&se=2022-04-10T10%3A431Z\&sr=c\&sp=l\&sig=ZJg9aovE%2BZXI</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 🗝TenantId : `String`                         | <p>The Azure Active Directory tenant (directory) Id.</p><p>Required for OAuth2 authentication method.</p><p><br>Default: <code>-</code><br>Example: <code>Y6b1hf2a-80e2-xyz2-qwer3h-3a7c3a8as4b7f</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 🗝ClientId : `String`                         | <p>The client (application) ID.</p><p>Required for OAuth2 authentication method.</p><p><br>Default: <code>-</code><br>Example: <code>Y6b1hf2a-80e2-xyz2-qwer3h-3a7c3a8as4b7f</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 🗝ClientSecret : `String`                     | <p>A client secret.</p><p>Required for OAuth2 authentication method.</p><p><br>Default: <code>-</code><br>Example: <code>Password</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| {% endtab %}                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

{% tab title="Parameter: Options" %}

| Name                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ExceptionHandler : `ExceptionHandlers` | <p>Determines how exceptions are handled during Task execution.</p><p>Setting this to ExceptionHandlers.Info will log the exception message to Result.Errors and attempt to continue the Task execution, if possible.</p><p>Possible values:</p><ul><li><code>Info</code>:</li></ul><p>Determines how exceptions are handled during Task execution.</p><p>Setting this to ExceptionHandlers.Info will log the exception message to Result.Errors and attempt to continue the Task execution, if possible.</p><ul><li><code>Throw</code>:</li></ul><p>Determines how exceptions are handled during Task execution.</p><p>Setting this to ExceptionHandlers.Info will log the exception message to Result.Errors and attempt to continue the Task execution, if possible.</p><p><br>Default: <code>0</code><br>Example: <code>ExceptionHandlers.Info</code></p> |
| ConsumeAttemptDelay : `Double`         | <p>Specifies the delay (in seconds) between each attempt to consume data.</p><p><br>Default: <code>1</code><br>Example: <code>1, 0.5</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| MaxRunTime : `Double`                  | <p>Sets the maximum duration (in seconds) for the Task to run.</p><p>If set to 0, the Task can run indefinitely.</p><p>Note that both MaxRunTime and MaxEvents cannot be set to unlimited.</p><p><br>Default: <code>0</code><br>Example: <code>0, 10, 1.5</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| MaxEvents : `Int32`                    | <p>Defines the maximum number of events to be received before ending the Task.</p><p>If set to 0, the Task can receive an unlimited number of events.</p><p>Note that both MaxRunTime and MaxEvents cannot be set to unlimited.</p><p><br>Default: <code>0</code><br>Example: <code>0, 5</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| {% endtab %}                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

{% tab title="Result: Result" %}

| Name                    | Description                                                                                                                                                     |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`     | <p>Indicates whether the Task completed without errors.<br>Example: <code>true</code></p>                                                                       |
| Data : `List<Object>`   | <p>Contains a list of events.<br>Example: <code>{ "foo", bar }</code></p>                                                                                       |
| Errors : `List<Object>` | <p>Contains a list of errors If Options.ExceptionHandlers is set to Throw.<br>Example: <code>{ "An exception occured", "Another exception occured" }</code></p> |
| {% endtab %}            |                                                                                                                                                                 |

{% tab title="Changelog" %}

## Changelog

### \[2.6.0] - 2026-01-16

#### Changed

* Update Azure packages to latest versions.
  * Azure.Identity to 1.17.1
  * Azure.Messaging.EventHubs to 5.12.2
  * Azure.Messaging.EventHubs.Processor to 5.12.2

### \[2.5.0] - 2025-09-22

#### Changed

* Show ContainerName parameter only when AuthenticationMethod is set to ConnectionString.

### \[2.4.0] - 2024-11-13

#### Changed

* Upgraded Azure.Messaging.EventHubs to version 5.11.5.
* Upgraded Azure.Messaging.EventHubs.Processor to version 5.11.5.

### \[2.3.0] - 2024-10-30

#### Fixed

* Issue #11 - Fixed Receive hanging in execution by adding a check for the MaximumWaitTime.

### \[2.2.0] - 2024-08-22

#### Added

* Updated Azure.Identity to the latest version 1.12.0.

### \[2.1.0] - 2024-05-31

#### Changed

* Replaced the List<> with a ConcurrentBag<> for the received messages.

### \[2.0.1] - 2023-11-29

#### Fixed

* Fixed ExceptionHandler check in catch and documentational fixes.

### \[2.0.0] - 2023-10-31

#### Added

* New property `Result.Errors`.

#### Changed

* Improved descriptions and examples.
* Errors and exceptions will be listed in `Result.Errors` if `Options.ExceptionHandler` is set to `ExceptionHandlers.Info`.
* Renamed `Options.MaximumWaitTimeInMinutes` to `Options.MaxRunTime`.
* `Options.MaxRunTime` (previously called `Options.MaximumWaitTimeInMinutes`) is now in seconds instead of minutes.
* `Consumer.MaximumWaitTime` cannot exceed `Options.MaxRunTime` when `Options.MaxRunTime` is greater than 0.
* Renamed `Consumer.FullyQualifiedNamespace` to `Consumer.Namespace`.
* Renamed `Options.Delay` to `Options.ConsumeAttemptDelay`.
* Package updates:
  * Azure.Identity 1.8.2 to 1.10.3
  * Azure.Messaging.EventHubs 5.9.0 to 5.9.3
  * Azure.Messaging.EventHubs.Processor 5.9.0 to 5.9.3
  * System.ComponentModel.Annotations 4.7.0 to 5.0.0

### \[1.0.0] - 2023-05-31

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
