Skip to content

Commit 4a65107

Browse files
Added section for Service Principal authentication.
1 parent c495c63 commit 4a65107

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Each connection factory is an instance of `ConnectionFactory`, `QueueConnectionF
5454
To simplify connecting with Azure Service Bus, these interfaces are implemented through `ServiceBusJmsConnectionFactory`, `ServiceBusJmsQueueConnectionFactory` and `ServiceBusJmsTopicConnectionFactory` respectively.
5555

5656
> [!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.
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. When using AAD backed authentication, ensure to [assign roles and permissions](service-bus-managed-service-identity.md#assigning-azure-roles-for-access-rights) to the identity as needed.
5858
5959
# [System Assigned Managed Identity](#tab/system-assigned-managed-identity-backed-authentication)
6060

@@ -64,15 +64,15 @@ Create a [system assigned managed identity](../active-directory/managed-identiti
6464
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();
6565
```
6666

67-
The Connection factory can then be instantiated with the below parameters.-
67+
The Connection factory can then be instantiated with the below parameters.
6868
* Token credential - Represents a credential capable of providing an OAuth token.
69-
* Connection string - the connection string for the Azure Service Bus Premium tier namespace.
69+
* Host - the hostname of the Azure Service Bus Premium tier namespace.
7070
* ServiceBusJmsConnectionFactorySettings property bag, which contains
7171
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.
7272
* traceFrames - boolean flag to collect AMQP trace frames for debugging.
7373
* *other configuration parameters*
7474

75-
The factory can be created as shown here. The connection string is a required parameter, but the other properties are optional.
75+
The factory can be created as shown here. The token credential and host are required parameters, but the other properties are optional.
7676

7777
```java
7878
String host = "<YourNamespaceName>.servicebus.windows.net";
@@ -89,15 +89,38 @@ TokenCredential tokenCredential = new DefaultAzureCredentialBuilder()
8989
.build();
9090
```
9191

92-
The Connection factory can then be instantiated with the below parameters.-
92+
The Connection factory can then be instantiated with the below parameters.
9393
* 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.
94+
* Host - the hostname of the Azure Service Bus Premium tier namespace.
9595
* ServiceBusJmsConnectionFactorySettings property bag, which contains
9696
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.
9797
* traceFrames - boolean flag to collect AMQP trace frames for debugging.
9898
* *other configuration parameters*
9999

100-
The factory can be created as shown here. The connection string is a required parameter, but the other properties are optional.
100+
The factory can be created as shown here. The token credential and host are required parameters, but the other properties are optional.
101+
102+
```java
103+
String host = "<YourNamespaceName>.servicebus.windows.net";
104+
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(tokenCredential, host, null);
105+
```
106+
107+
# [Service Principal](#tab/service-principal-backed-authentication)
108+
109+
Create a [service principal](authenticate-application.md#register-your-application-with-an-azure-ad-tenant) on Azure, and use this identity to create a `TokenCredential`.
110+
111+
```java
112+
TokenCredential tokenCredential = new ClientSecretCredential("<tenant_id>", "<client_id>", "<client_secret>").build();
113+
```
114+
115+
The Connection factory can then be instantiated with the below parameters.
116+
* Token credential - Represents a credential capable of providing an OAuth token.
117+
* Host - the hostname of the Azure Service Bus Premium tier namespace.
118+
* ServiceBusJmsConnectionFactorySettings property bag, which contains
119+
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.
120+
* traceFrames - boolean flag to collect AMQP trace frames for debugging.
121+
* *other configuration parameters*
122+
123+
The factory can be created as shown here. The token credential and host are required parameters, but the other properties are optional.
101124

102125
```java
103126
String host = "<YourNamespaceName>.servicebus.windows.net";
@@ -106,7 +129,7 @@ ConnectionFactory factory = new ServiceBusJmsConnectionFactory(tokenCredential,
106129

107130
# [Connection string authentication](#tab/connection-string-authentication)
108131

109-
The Connection factory can be instantiated with the below parameters -
132+
The Connection factory can be instantiated with the below parameters.
110133
* Connection string - the connection string for the Azure Service Bus Premium tier namespace.
111134
* ServiceBusJmsConnectionFactorySettings property bag, which contains
112135
* connectionIdleTimeoutMS - idle connection timeout in milliseconds.

0 commit comments

Comments
 (0)