|
1 | 1 | --- |
2 | | -author: mattchenderson |
| 2 | +author: ggailey777 |
3 | 3 | ms.service: azure-functions |
4 | 4 | ms.topic: include |
5 | | -ms.date: 10/08/2021 |
6 | | -ms.author: mahender |
| 5 | +ms.date: 04/13/2026 |
| 6 | +ms.author: glenga |
7 | 7 | --- |
8 | 8 |
|
9 | 9 | ## Connections |
10 | 10 |
|
11 | 11 | The `connection` property is a reference to environment configuration which specifies how the app should connect to Event Hubs. It may specify: |
12 | 12 |
|
13 | | -- The name of an application setting containing a [connection string](#connection-string) |
14 | | -- The name of a shared prefix for multiple application settings, together defining an [identity-based connection](#identity-based-connections). |
| 13 | +- The name of an application setting containing a connection string. |
| 14 | +- The name of a shared prefix for multiple application settings, together defining a managed identity connection. |
15 | 15 |
|
16 | 16 | If the configured value is both an exact match for a single setting and a prefix match for other settings, the exact match is used. |
17 | 17 |
|
18 | | -### Connection string |
| 18 | +> [!TIP] |
| 19 | +> Managed identity connections are recommended over connection strings for improved security. Connection strings include credentials that could be exposed, while managed identities eliminate the need to manage secrets. |
19 | 20 |
|
20 | | -Obtain this connection string by clicking the **Connection Information** button for the [namespace](../articles/event-hubs/event-hubs-create.md#create-an-event-hubs-namespace), not the event hub itself. The connection string must be for an Event Hubs namespace, not the event hub itself. |
| 21 | +### [Managed identity](#tab/identity-based) |
21 | 22 |
|
22 | | -When used for triggers, the connection string must have at least "read" permissions to activate the function. When used for output bindings, the connection string must have "send" permissions to send messages to the event stream. |
| 23 | +If you are using [version 5.x or higher of the extension](../articles/azure-functions/functions-bindings-event-hubs.md?tabs=extensionv5), instead of using a connection string with a secret, you can have the app use a [Microsoft Entra identity](../articles/active-directory/fundamentals/active-directory-whatis.md). To do this, you would define settings under a common prefix which maps to the `connection` property in the trigger and binding configuration. |
23 | 24 |
|
24 | | -This connection string should be stored in an application setting with a name matching the value specified by the `connection` property of the binding configuration. |
| 25 | +In this mode, the extension requires the following application settings: |
25 | 26 |
|
26 | | -### Identity-based connections |
| 27 | +| Template-based setting | Description | Identity type | |
| 28 | +| --- | --- | --- | |
| 29 | +| `<CONNECTION_NAME_PREFIX>__fullyQualifiedNamespace` | The fully qualified Event Hubs namespace. | System-assigned or user-assigned | |
| 30 | +| `<CONNECTION_NAME_PREFIX>__credential` | Must be set to `managedidentity`. | User-assigned | |
| 31 | +| `<CONNECTION_NAME_PREFIX>__clientId` | The client ID of the user-assigned managed identity. | User-assigned | |
27 | 32 |
|
28 | | -If you are using [version 5.x or higher of the extension](../articles/azure-functions/functions-bindings-event-hubs.md?tabs=extensionv5), instead of using a connection string with a secret, you can have the app use a [Microsoft Entra identity](../articles/active-directory/fundamentals/active-directory-whatis.md). To do this, you would define settings under a common prefix which maps to the `connection` property in the trigger and binding configuration. |
| 33 | +The value that you replace `<CONNECTION_NAME_PREFIX>` with is treated by the binding extension as the name of the connection setting. |
| 34 | + |
| 35 | +For example, if your binding configuration specifies `connection = "EventHubConnection"` with a user-assigned managed identity, you would configure the following application settings: |
29 | 36 |
|
30 | | -In this mode, the extension requires the following properties: |
| 37 | +```json |
| 38 | +{ |
| 39 | + "EventHubConnection__fullyQualifiedNamespace": "myeventhubns.servicebus.windows.net", |
| 40 | + "EventHubConnection__credential": "managedidentity", |
| 41 | + "EventHubConnection__clientId": "00000000-0000-0000-0000-000000000000" |
| 42 | +} |
| 43 | +``` |
31 | 44 |
|
32 | | -| Property | Environment variable template | Description | Example value | |
33 | | -|--------------|----------|-----|----------| |
34 | | -| Fully Qualified Namespace | `<CONNECTION_NAME_PREFIX>__fullyQualifiedNamespace` | The fully qualified Event Hubs namespace. | `myeventhubns.servicebus.windows.net`| |
| 45 | +> [!TIP] |
| 46 | +> Use user-assigned managed identities for production scenarios where you need fine-grained control over identity permissions across multiple resources. |
35 | 47 |
|
36 | | -Additional properties may be set to customize the connection. See [Common properties for identity-based connections](../articles/azure-functions/functions-reference.md#common-properties-for-identity-based-connections). |
| 48 | +You can use additional settings in the template to further customize the connection. See [Common properties for identity-based connections](../articles/azure-functions/functions-reference.md#common-properties-for-identity-based-connections). |
37 | 49 |
|
38 | 50 | > [!NOTE] |
39 | 51 | > When using [Azure App Configuration](../articles/azure-app-configuration/quickstart-azure-functions-csharp.md) or [Key Vault](/azure/key-vault/general/overview) to provide settings for Managed Identity connections, setting names should use a valid key separator such as `:` or `/` in place of the `__` to ensure names are resolved correctly. |
40 | | -> |
41 | | -> For example, `<CONNECTION_NAME_PREFIX>:fullyQualifiedNamespace`. |
| 52 | +> |
| 53 | +> For example: `EventHubConnection:fullyQualifiedNamespace` |
42 | 54 |
|
43 | 55 | [!INCLUDE [functions-identity-based-connections-configuration](./functions-identity-based-connections-configuration.md)] |
44 | 56 |
|
45 | 57 | [!INCLUDE [functions-event-hubs-permissions](./functions-event-hubs-permissions.md)] |
| 58 | + |
| 59 | +### [Connection string](#tab/connection-string) |
| 60 | + |
| 61 | +Obtain this connection string by clicking the **Connection Information** button for the [namespace](../articles/event-hubs/event-hubs-create.md#create-an-event-hubs-namespace), not the event hub itself. The connection string must be for an Event Hubs namespace, not the event hub itself. |
| 62 | + |
| 63 | +When used for triggers, the connection string must have at least "read" permissions to activate the function. When used for output bindings, the connection string must have "send" permissions to send messages to the event stream. |
| 64 | + |
| 65 | +This connection string should be stored in an application setting with a name matching the value specified by the `connection` property of the binding configuration. |
| 66 | + |
| 67 | +--- |
0 commit comments