Skip to content

Commit 961fec0

Browse files
authored
Merge pull request #104338 from spelluru/ehubkafkaoauth0212
Kafka - OAuth updates
2 parents 64f730e + bd19b28 commit 961fec0

5 files changed

+91
-39
lines changed

articles/event-hubs/authenticate-managed-identity.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,17 @@ var ehClient = EventHubClient.CreateWithManagedIdentity(new Uri($"sb://{EventHub
133133
```
134134
---
135135

136+
## Event Hubs for Kafka
137+
You can use Apache Kafka applications to send messages to and receive messages from Azure Event Hubs using managed identity OAuth. See the following sample on GitHub: [Event Hubs for Kafka - send and receive messages using managed identity OAuth](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth/java/managedidentity).
138+
136139
## Samples
137140
- [Microsoft.Azure.EventHubs samples](https://github.com/Azure/azure-event-hubs/tree/master/samples/DotNet/Microsoft.Azure.EventHubs/Rbac).
138141

139142
These samples use the old **Microsoft.Azure.EventHubs** library, but you can easily update it to using the latest **Azure.Messaging.EventHubs** library. To move the sample from using the old library to new one, see the [Guide to migrate from Microsoft.Azure.EventHubs to Azure.Messaging.EventHubs](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/eventhub/Azure.Messaging.EventHubs/migration-guide-from-v4.md).
140143
- [Azure.Messaging.EventHubs samples](https://github.com/Azure/azure-event-hubs/tree/master/samples/DotNet/Azure.Messaging.EventHubs/ManagedIdentityWebApp)
141144

142145
This sample has been updated to use the latest **Azure.Messaging.EventHubs** library.
146+
- [Event Hubs for Kafka - send and receive messages using managed identity OAuth](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth/java/managedidentity)
143147

144148

145149
## Next steps

articles/event-hubs/authorize-access-azure-active-directory.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,23 @@ The following list describes the levels at which you can scope access to Event H
5151
- **Subscription**: Role assignment applies to all the Event Hubs resources in all of the resource groups in the subscription.
5252

5353
> [!NOTE]
54-
> Keep in mind that RBAC role assignments may take up to five minutes to propagate.
54+
> - Keep in mind that RBAC role assignments may take up to five minutes to propagate.
55+
> - This content applies to both Event Hubs and Event Hubs for Apache Kafka. For more information on Event Hubs for Kafka support, see [Event Hubs for Kafka - security and authentication](event-hubs-for-kafka-ecosystem-overview.md#security-and-authentication).
56+
5557

5658
For more information about how built-in roles are defined, see [Understand role definitions](../role-based-access-control/role-definitions.md#management-and-data-operations). For information about creating custom RBAC roles, see [Create custom roles for Azure Role-Based Access Control](../role-based-access-control/custom-roles.md).
5759

60+
61+
5862
## Samples
5963
- [Microsoft.Azure.EventHubs samples](https://github.com/Azure/azure-event-hubs/tree/master/samples/DotNet/Microsoft.Azure.EventHubs/Rbac).
6064

6165
These samples use the old **Microsoft.Azure.EventHubs** library, but you can easily update it to using the latest **Azure.Messaging.EventHubs** library. To move the sample from using the old library to new one, see the [Guide to migrate from Microsoft.Azure.EventHubs to Azure.Messaging.EventHubs](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/eventhub/Azure.Messaging.EventHubs/migration-guide-from-v4.md).
6266
- [Azure.Messaging.EventHubs samples](https://github.com/Azure/azure-event-hubs/tree/master/samples/DotNet/Azure.Messaging.EventHubs/ManagedIdentityWebApp)
6367

6468
This sample has been updated to use the latest **Azure.Messaging.EventHubs** library.
69+
- [Event Hubs for Kafka - OAuth samples](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth).
70+
6571

6672
## Next steps
6773
- Learn how to assign a built-in-RBAC role to a security principal, see [Authenticate access to Event Hubs resources using Azure Active Directory](authenticate-application.md).

articles/event-hubs/authorize-access-event-hubs.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ documentationcenter: ''
77
author: spelluru
88

99
ms.topic: conceptual
10-
ms.date: 08/22/2019
10+
ms.date: 02/12/2020
1111
ms.author: spelluru
1212

1313
---
@@ -16,6 +16,12 @@ Every time you publish or consume events/data from an event hub, your client is
1616

1717
Azure Event Hubs offers the following options for authorizing access to secure resources:
1818

19+
- Azure Active Directory
20+
- Shared access signature
21+
22+
> [!NOTE]
23+
> This article applies to both Event Hubs and [Apache Kafka](event-hubs-for-kafka-ecosystem-overview.md) scenarios.
24+
1925
## Azure Active Directory
2026
Azure Active Directory (Azure AD) integration for Event Hubs resources provides role-based access control (RBAC) for fine-grained control over a client’s access to resources. You can use role-based access control (RBAC) to grant permissions to security principal, which may be a user, a group, or an application service principal. The security principal is authenticated by Azure AD to return an OAuth 2.0 token. The token can be used to authorize a request to access an Event Hubs resource.
2127

articles/event-hubs/event-hubs-for-kafka-ecosystem-overview.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: timlt
99
ms.service: event-hubs
1010
ms.topic: article
1111
ms.custom: seodec18
12-
ms.date: 12/06/2018
12+
ms.date: 02/12/2020
1313
ms.author: shvija
1414

1515
---
@@ -20,7 +20,7 @@ Event Hubs provides a Kafka endpoint that can be used by your existing Kafka bas
2020

2121
The Event Hubs for Kafka feature provides a protocol head on top of Azure Event Hubs that is binary compatible with Kafka versions 1.0 and later for both reading from and writing to Kafka topics. You may start using the Kafka endpoint from your applications with no code change but a minimal configuration change. You update the connection string in configurations to point to the Kafka endpoint exposed by your event hub instead of pointing to your Kafka cluster. Then, you can start streaming events from your applications that use the Kafka protocol into Event Hubs. This integration also supports frameworks like [Kafka Connect](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/connect), which is currently in preview.
2222

23-
Conceptually Kafka and Event Hubs are nearly identical: they are both partitioned logs built for streaming data. The following table maps concepts between Kafka and Event Hubs.
23+
Conceptually Kafka and Event Hubs are nearly identical: they're both partitioned logs built for streaming data. The following table maps concepts between Kafka and Event Hubs.
2424

2525
### Kafka and Event Hub conceptual mapping
2626

@@ -34,13 +34,43 @@ Conceptually Kafka and Event Hubs are nearly identical: they are both partitione
3434

3535
### Key differences between Kafka and Event Hubs
3636

37-
While [Apache Kafka](https://kafka.apache.org/) is software, which you can run wherever you choose, Event Hubs is a cloud service similar to Azure Blob Storage. There are no servers or networks to manage and no brokers to configure. You create a namespace, which is an FQDN in which your topics live, and then create Event Hubs or topics within that namespace. For more information about Event Hubs and namespaces, see [Event Hubs features](event-hubs-features.md#namespace). As a cloud service, Event Hubs uses a single stable virtual IP address as the endpoint, so clients do not need to know about the brokers or machines within a cluster.
37+
While [Apache Kafka](https://kafka.apache.org/) is software, which you can run wherever you choose, Event Hubs is a cloud service similar to Azure Blob Storage. There are no servers or networks to manage and no brokers to configure. You create a namespace, which is an FQDN in which your topics live, and then create Event Hubs or topics within that namespace. For more information about Event Hubs and namespaces, see [Event Hubs features](event-hubs-features.md#namespace). As a cloud service, Event Hubs uses a single stable virtual IP address as the endpoint, so clients don't need to know about the brokers or machines within a cluster.
3838

3939
Scale in Event Hubs is controlled by how many throughput units you purchase, with each throughput unit entitling you to 1 MB per second, or 1000 events per second of ingress. By default, Event Hubs scales up throughput units when you reach your limit with the [Auto-Inflate](event-hubs-auto-inflate.md) feature; this feature also works with the Event Hubs for Kafka feature.
4040

4141
### Security and authentication
42+
Every time you publish or consume events from an Event Hubs for Kafka, your client is trying to access the Event Hubs resources. You want to ensure that the resources are accessed using an authorized entity. When using Apache Kafka protocol with your clients, you can set your configuration for authentication and encryption using the SASL mechanisms. When using Event Hubs for Kafka requires the TLS-encryption (as all data in transit with Event Hubs is TLS encrypted). It can be done specifying the SASL_SSL option in your configuration file.
4243

43-
Azure Event Hubs requires SSL or TLS for all communication and uses Shared Access Signatures (SAS) for authentication. This requirement is also true for a Kafka endpoint within Event Hubs. For compatibility with Kafka, Event Hubs uses SASL PLAIN for authentication and SASL SSL for transport security. For more information about security in Event Hubs, see [Event Hubs authentication and security](event-hubs-authentication-and-security-model-overview.md).
44+
Azure Event Hubs provides multiple options to authorize access to your secure resources.
45+
46+
- OAuth
47+
- Shared access signature (SAS)
48+
49+
#### OAuth
50+
Event Hubs integrates with Azure Active Directory (Azure AD), which provides a **OAuth** 2.0 compliant centralized authorization server. With Azure AD, you can use role-based access control (RBAC) to grant fine grained permissions to your client identities. You can use this feature with your Kafka clients by specifying **SASL_SSL** for the protocol and **OAUTHBEARER** for the mechanism. For details about RBAC roles and levels for scoping access, see [Authorize access with Azure AD](authorize-access-azure-active-directory.md).
51+
52+
```xml
53+
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
54+
security.protocol=SASL_SSL
55+
sasl.mechanism=OAUTHBEARER
56+
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;
57+
sasl.login.callback.handler.class=CustomAuthenticateCallbackHandler;
58+
```
59+
60+
#### Shared Access Signature (SAS)
61+
Event Hubs also provides the **Shared Access Signatures (SAS)** for delegated access to Event Hubs for Kafka resources. Authorizing access using OAuth 2.0 token-based mechanism provides superior security and ease of use over SAS. The built-in roles can also eliminate the need for ACL-based authorization, which has to be maintained and managed by the user. You can use this feature with your Kafka clients by specifying **SASL_SSL** for the protocol and **PLAIN** for the mechanism.
62+
63+
```xml
64+
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
65+
security.protocol=SASL_SSL
66+
sasl.mechanism=PLAIN
67+
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}";
68+
```
69+
70+
#### Samples
71+
For a **tutorial** with step-by-step instructions to create a Kafka enabled event hub and access it using SAS or OAuth, see [Quickstart: Data streaming with Event Hubs using the Kafka protocol](event-hubs-quickstart-kafka-enabled-event-hubs.md).
72+
73+
For more **samples** that show how to use OAuth with Event Hubs for Kafka, see [samples on GitHub](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth).
4474

4575
## Other Event Hubs features available for Kafka
4676

articles/event-hubs/event-hubs-quickstart-kafka-enabled-event-hubs.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.author: shvija
77
ms.service: event-hubs
88
ms.topic: quickstart
99
ms.custom: seodec18
10-
ms.date: 11/05/2019
10+
ms.date: 02/12/2020
1111
---
1212

1313
# Quickstart: Data streaming with Event Hubs using the Kafka protocol
@@ -28,28 +28,7 @@ To complete this quickstart, make sure you have the following prerequisites:
2828
* [A Kafka enabled Event Hubs namespace](event-hubs-create.md)
2929

3030
## Create a Kafka enabled Event Hubs namespace
31-
32-
1. Sign in to the [Azure portal](https://portal.azure.com), and click **Create a resource** at the top left of the screen.
33-
34-
2. Search for Event Hubs and select the options shown here:
35-
36-
![Search for Event Hubs in the portal](./media/event-hubs-create-kafka-enabled/event-hubs-create-event-hubs.png)
37-
38-
3. Provide a unique name and enable Kafka on the namespace. Click **Create**. Note: Event Hubs for Kafka is only supported by Standard and Dedicated tier Event Hubs. Basic tier Event Hubs will return a Topic Authorization Error in response to any Kafka operations.
39-
40-
![Create a namespace](./media/event-hubs-create-kafka-enabled/create-kafka-namespace.jpg)
41-
42-
4. Once the namespace is created, on the **Settings** tab click **Shared access policies** to get the connection string.
43-
44-
![Click Shared access policies](./media/event-hubs-create/create-event-hub7.png)
45-
46-
5. You can choose the default **RootManageSharedAccessKey**, or add a new policy. Click the policy name and copy the connection string.
47-
48-
![Select a policy](./media/event-hubs-create/create-event-hub8.png)
49-
50-
6. Add this connection string to your Kafka application configuration.
51-
52-
You can now stream events from your applications that use the Kafka protocol into Event Hubs.
31+
When you create a standard tier Event Hubs namespace, the Kafka endpoint for the namespace is automatically enabled. You can stream events from your applications that use the Kafka protocol into standard tier Event Hubs. It's not enabled for the basic tier Event Hubs namespace.
5332

5433
## Send and receive messages with Kafka in Event Hubs
5534

@@ -59,14 +38,26 @@ You can now stream events from your applications that use the Kafka protocol int
5938

6039
3. Update the configuration details for the producer in `src/main/resources/producer.config` as follows:
6140

41+
**SSL:**
42+
6243
```xml
63-
bootstrap.servers={YOUR.EVENTHUBS.FQDN}:9093
44+
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
6445
security.protocol=SASL_SSL
6546
sasl.mechanism=PLAIN
6647
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}";
6748
```
68-
69-
4. Run the producer code and stream into Kafka-enabled Event Hubs:
49+
**OAuth:**
50+
51+
```xml
52+
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
53+
security.protocol=SASL_SSL
54+
sasl.mechanism=OAUTHBEARER
55+
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;
56+
sasl.login.callback.handler.class=CustomAuthenticateCallbackHandler;
57+
```
58+
59+
You can find the source code for the sample handler class CustomAuthenticateCallbackHandler on GitHub [here](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth/java/appsecret/producer/src/main/java).
60+
4. Run the producer code and stream events into Kafka-enabled Event Hubs:
7061

7162
```shell
7263
mvn clean package
@@ -77,13 +68,28 @@ You can now stream events from your applications that use the Kafka protocol int
7768

7869
6. Update the configuration details for the consumer in `src/main/resources/consumer.config` as follows:
7970

71+
**SSL:**
72+
8073
```xml
81-
bootstrap.servers={YOUR.EVENTHUBS.FQDN}:9093
74+
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
8275
security.protocol=SASL_SSL
8376
sasl.mechanism=PLAIN
8477
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{YOUR.EVENTHUBS.CONNECTION.STRING}";
8578
```
8679

80+
**OAuth:**
81+
82+
```xml
83+
bootstrap.servers=NAMESPACENAME.servicebus.windows.net:9093
84+
security.protocol=SASL_SSL
85+
sasl.mechanism=OAUTHBEARER
86+
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;
87+
sasl.login.callback.handler.class=CustomAuthenticateCallbackHandler;
88+
```
89+
90+
You can find the source code for the sample handler class CustomAuthenticateCallbackHandler on GitHub [here](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth/java/appsecret/consumer/src/main/java).
91+
92+
You can find all the OAuth samples for Event Hubs for Kafka [here](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials/oauth).
8793
7. Run the consumer code and process from Kafka enabled Event Hubs using your Kafka clients:
8894

8995
```java
@@ -94,10 +100,10 @@ You can now stream events from your applications that use the Kafka protocol int
94100
If your Event Hubs Kafka cluster has events, you now start receiving them from the consumer.
95101

96102
## Next steps
97-
In this article, you learned how to stream into Kafka-enabled Event Hubs without changing your protocol clients or running your own clusters. To learn more, continue with the following tutorial:
103+
In this article, you learned how to stream into Kafka-enabled Event Hubs without changing your protocol clients or running your own clusters. To learn more, see the following articles and samples:
98104

99-
* [Learn about Event Hubs](event-hubs-what-is-event-hubs.md)
100-
* [Learn about Event Hubs for Kafka](event-hubs-for-kafka-ecosystem-overview.md)
101-
* [Explore more samples on the Event Hubs for Kafka GitHub](https://github.com/Azure/azure-event-hubs-for-kafka)
102-
* Use [MirrorMaker](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27846330) to [stream events from Kafka on premises to Kafka enabled Event Hubs on cloud.](event-hubs-kafka-mirror-maker-tutorial.md)
103-
* Learn how to stream into Kafka enabled Event Hubs using [Apache Flink](event-hubs-kafka-flink-tutorial.md) or [Akka Streams](event-hubs-kafka-akka-streams-tutorial.md)
105+
- [Learn about Event Hubs for Kafka](event-hubs-for-kafka-ecosystem-overview.md)
106+
- [Quickstarts for Event Hubs for Kafka on GitHub](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/quickstart)
107+
- [Tutorials for Event Hubs for Kafka on GitHub](https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/tutorials)
108+
- Use [MirrorMaker](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27846330) to [stream events from Kafka on premises to Kafka enabled Event Hubs on cloud.](event-hubs-kafka-mirror-maker-tutorial.md)
109+
- Learn how to stream into Kafka enabled Event Hubs using [Apache Flink](event-hubs-kafka-flink-tutorial.md) or [Akka Streams](event-hubs-kafka-akka-streams-tutorial.md)

0 commit comments

Comments
 (0)