Skip to content

Commit 08cc380

Browse files
Added documentation for AAD authentication for Service Bus JMS API
1 parent ab595d2 commit 08cc380

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

articles/service-bus-messaging/jms-developer-guide.md

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ The connection factory object is used by the client to connect with the JMS prov
5151

5252
Each connection factory is an instance of `ConnectionFactory`, `QueueConnectionFactory` or `TopicConnectionFactory` interface.
5353

54-
To simplify connecting with Azure Service Bus, these interfaces are implemented through `ServiceBusJmsConnectionFactory`, `ServiceBusJmsQueueConnectionFactory` and `ServiceBusJmsTopicConnectionFactory` respectively. The Connection factory can be instantiated with the below parameters -
54+
To simplify connecting with Azure Service Bus, these interfaces are implemented through `ServiceBusJmsConnectionFactory`, `ServiceBusJmsQueueConnectionFactory` and `ServiceBusJmsTopicConnectionFactory` respectively.
55+
56+
> [!IMPORTANT]
57+
> Java applications leveraging JMS 2.0 API can connect to Azure Service Bus using the connection string, or using a `TokenCredential` for leveraging Azure Active Directory (AAD) backed authentication.
58+
59+
# [System Assigned Managed Identity](#tab/system-assigned-managed-identity-backed-authentication)
60+
61+
Create a [system assigned managed identity](/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vm) on Azure, and use this to create a `TokenCredential`.
62+
63+
```java
64+
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();
65+
```
66+
67+
The Connection factory can than be instantiated with the below parameters.-
68+
* Token credential - Represents a credential capable of providing an OAuth token.
5569
* Connection string - the connection string for the Azure Service Bus Premium tier namespace.
5670
* ServiceBusJmsConnectionFactorySettings property bag which contains
5771
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.
@@ -61,14 +75,49 @@ To simplify connecting with Azure Service Bus, these interfaces are implemented
6175
The factory can be created as below. The connection string is a required parameter, but the additional properties are optional.
6276

6377
```java
64-
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(SERVICE_BUS_CONNECTION_STRING, null);
78+
String host = "<YourNamespaceName>.servicebus.windows.net";
79+
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(tokenCredential, host, null);
6580
```
6681

67-
> [!IMPORTANT]
68-
> Java applications leveraging JMS 2.0 API must connect to Azure Service Bus using the connection string only. Currently, authentication for JMS clients is only supported using the Connection string.
69-
>
70-
> Azure active directory (AAD) backed authentication is not currently supported.
71-
>
82+
# [User Assigned Managed Identity](#tab/user-assigned-managed-identity-backed-authentication)
83+
84+
Create a [user assigned managed identity](/active-directory/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp#create-a-user-assigned-managed-identity) on Azure, and use this to create a `TokenCredential`.
85+
86+
```java
87+
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder()
88+
.managedIdentityClientId("<clientIDOfUserAssignedIdentity>")
89+
.build();
90+
```
91+
92+
The Connection factory can than be instantiated with the below parameters.-
93+
* Token credential - Represents a credential capable of providing an OAuth token.
94+
* Connection string - the connection string for the Azure Service Bus Premium tier namespace.
95+
* ServiceBusJmsConnectionFactorySettings property bag which contains
96+
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.
97+
* traceFrames - boolean flag to collect AMQP trace frames for debugging.
98+
* *other configuration parameters*
99+
100+
The factory can be created as below. The connection string is a required parameter, but the additional properties are optional.
101+
102+
```java
103+
String host = "<YourNamespaceName>.servicebus.windows.net";
104+
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(tokenCredential, host, null);
105+
```
106+
107+
# [Connection string authentication](#tab/connection-string-authentication)
108+
109+
The Connection factory can be instantiated with the below parameters -
110+
* Connection string - the connection string for the Azure Service Bus Premium tier namespace.
111+
* ServiceBusJmsConnectionFactorySettings property bag which contains
112+
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.
113+
* traceFrames - boolean flag to collect AMQP trace frames for debugging.
114+
* *other configuration parameters*
115+
116+
The factory can be created as below. The connection string is a required parameter, but the additional properties are optional.
117+
118+
```java
119+
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(SERVICE_BUS_CONNECTION_STRING, null);
120+
```
72121

73122
### JMS destination
74123

articles/service-bus-messaging/migrate-jms-activemq-to-servicebus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ As part of migrating and modifying your client applications to interact with Azu
5858

5959
#### Authentication and authorization
6060

61-
Azure role-based access control (Azure RBAC), backed by Azure Active Directory, is the preferred authentication mechanism for Service Bus. Because Azure RBAC, or claim-based authentication, isn't currently supported by Apache QPID JMS, however, you should use SAS keys for authentication.
61+
Azure role-based access control (Azure RBAC), backed by Azure Active Directory, is the preferred authentication mechanism for Service Bus. To enable role-based access control, please follow the steps in the [Azure Service Bus JMS 2.0 developer guide](jms-developer-guide.md).
6262

6363
## Pre-migration
6464

0 commit comments

Comments
 (0)