Skip to content

Commit 0c2e0ec

Browse files
committed
Combine Java and JMS tabs
1 parent c5d80b5 commit 0c2e0ec

File tree

1 file changed

+66
-73
lines changed

1 file changed

+66
-73
lines changed

articles/service-bus-messaging/service-bus-migrate-azure-credentials.md

Lines changed: 66 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ await using var client = new ServiceBusClient("<CONNECTION-STRING>");
3434

3535
## [Java](#tab/java)
3636

37+
**JMS:**
38+
39+
```java
40+
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(
41+
"<CONNECTION-STRING>",
42+
new ServiceBusJmsConnectionFactorySettings());
43+
```
44+
3745
**Receiver client:**
3846

3947
```java
@@ -55,14 +63,6 @@ ServiceBusSenderClient client = new ServiceBusClientBuilder()
5563
.buildClient();
5664
```
5765

58-
## [Java - JMS](#tab/java-jms)
59-
60-
```java
61-
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(
62-
"<CONNECTION-STRING>",
63-
new ServiceBusJmsConnectionFactorySettings());
64-
```
65-
6666
## [Node.js](#tab/nodejs)
6767

6868
```nodejs
@@ -115,7 +115,7 @@ Next, update your code to use passwordless connections.
115115
using Azure.Identity;
116116
```
117117

118-
1. Identify the locations in your code that create a `ServiceBusClient` object to connect to Azure Service Bus. Update your code to match the following example:
118+
1. Identify the code that creates a `ServiceBusClient` object to connect to Azure Service Bus. Update your code to match the following example:
119119

120120
```csharp
121121
//TODO: Replace the <SERVICE-BUS-NAMESPACE-NAME> placeholder.
@@ -126,77 +126,70 @@ Next, update your code to use passwordless connections.
126126

127127
## [Java](#tab/java)
128128

129-
1. To use `DefaultAzureCredential` in a Java application, install the `azure-identity` package via one of the following approaches:
130-
1. [Include the BOM file](/java/api/overview/azure/identity-readme?view=azure-java-stable&preserve-view=true#include-the-bom-file).
131-
1. [Include a direct dependency](/java/api/overview/azure/identity-readme?view=azure-java-stable&preserve-view=true#include-direct-dependency).
132-
133-
1. At the top of your file, add the following code:
134-
135-
```java
136-
import com.azure.identity.DefaultAzureCredentialBuilder;
137-
```
129+
1. To use `DefaultAzureCredential`:
130+
- In a JMS application, add at least version 1.0.0 of the `azure-servicebus-jms` package to your application:
138131

139-
1. Identify the locations in your code that create a Service Bus sender or receiver client object to connect to Azure Service Bus. Update your code to match one of the following examples:
132+
```xml
133+
<dependency>
134+
<groupId>com.microsoft.azure</groupId>
135+
<artifactId>azure-servicebus-jms</artifactId>
136+
<version>1.0.0</version>
137+
</dependency>
138+
```
140139

141-
**Receiver client:**
140+
- In a Java application, install the `azure-identity` package via one of the following approaches:
141+
1. [Include the BOM file](/java/api/overview/azure/identity-readme?view=azure-java-stable&preserve-view=true#include-the-bom-file).
142+
1. [Include a direct dependency](/java/api/overview/azure/identity-readme?view=azure-java-stable&preserve-view=true#include-direct-dependency).
142143

143-
```java
144-
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
145-
.build();
146-
147-
ServiceBusReceiverClient receiver = new ServiceBusClientBuilder()
148-
.credential("<SERVICE-BUS-NAMESPACE-NAME>.servicebus.windows.net", credential)
149-
.receiver()
150-
.topicName("<TOPIC-NAME>")
151-
.subscriptionName("<SUBSCRIPTION-NAME>")
152-
.buildClient();
153-
```
154-
155-
**Sender client:**
156-
157-
```java
158-
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
159-
.build();
160-
161-
// TODO: Update the <SERVICE-BUS-NAMESPACE-NAME> placeholder.
162-
ServiceBusSenderClient client = new ServiceBusClientBuilder()
163-
.credential("<SERVICE-BUS-NAMESPACE-NAME>.servicebus.windows.net", credential)
164-
.sender()
165-
.queueName("<QUEUE-NAME>")
166-
.buildClient();
167-
```
168-
169-
## [Java - JMS](#tab/java-jms)
170-
171-
1. To use `DefaultAzureCredential` in a JMS application, add at least version 1.0.0 of the `azure-servicebus-jms` package to your application:
172-
173-
```xml
174-
<dependency>
175-
<groupId>com.microsoft.azure</groupId>
176-
<artifactId>azure-servicebus-jms</artifactId>
177-
<version>1.0.0</version>
178-
</dependency>
179-
```
180-
181144
1. At the top of your file, add the following code:
182145

183146
```java
184-
import com.azure.core.credential.TokenCredential;
185147
import com.azure.identity.DefaultAzureCredentialBuilder;
186148
```
187149

188-
1. Identify the locations in your code that currently create a `ServiceBusJmsConnectionFactory` object to connect to Azure Service Bus. Update your code to match the following example:
189-
190-
```java
191-
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
192-
.build();
150+
1. Update the code that connects to Azure Service Bus:
151+
- In a JMS application, identify the code that creates a `ServiceBusJmsConnectionFactory` object to connect to Azure Service Bus. Update your code to match the following example:
193152

194-
//TODO: Replace the "<SERVICE-BUS-NAMESPACE-NAME>" placeholder.
195-
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(
196-
credential,
197-
"<SERVICE-BUS-NAMESPACE-NAME>.servicebus.windows.net",
198-
new ServiceBusJmsConnectionFactorySettings());
199-
```
153+
```java
154+
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
155+
.build();
156+
157+
//TODO: Replace the <SERVICE-BUS-NAMESPACE-NAME> placeholder.
158+
ConnectionFactory factory = new ServiceBusJmsConnectionFactory(
159+
credential,
160+
"<SERVICE-BUS-NAMESPACE-NAME>.servicebus.windows.net",
161+
new ServiceBusJmsConnectionFactorySettings());
162+
```
163+
164+
- In a Java application, identify the code that creates a Service Bus sender or receiver client object to connect to Azure Service Bus. Update your code to match one of the following examples:
165+
166+
**Receiver client:**
167+
168+
```java
169+
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
170+
.build();
171+
172+
ServiceBusReceiverClient receiver = new ServiceBusClientBuilder()
173+
.credential("<SERVICE-BUS-NAMESPACE-NAME>.servicebus.windows.net", credential)
174+
.receiver()
175+
.topicName("<TOPIC-NAME>")
176+
.subscriptionName("<SUBSCRIPTION-NAME>")
177+
.buildClient();
178+
```
179+
180+
**Sender client:**
181+
182+
```java
183+
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
184+
.build();
185+
186+
// TODO: Update the <SERVICE-BUS-NAMESPACE-NAME> placeholder.
187+
ServiceBusSenderClient client = new ServiceBusClientBuilder()
188+
.credential("<SERVICE-BUS-NAMESPACE-NAME>.servicebus.windows.net", credential)
189+
.sender()
190+
.queueName("<QUEUE-NAME>")
191+
.buildClient();
192+
```
200193

201194
## [Node.js](#tab/nodejs)
202195

@@ -212,7 +205,7 @@ Next, update your code to use passwordless connections.
212205
const { DefaultAzureCredential } = require("@azure/identity");
213206
```
214207

215-
1. Identify the locations in your code that create a `ServiceBusClient` object to connect to Azure Service Bus. Update your code to match the following example:
208+
1. Identify the code that creates a `ServiceBusClient` object to connect to Azure Service Bus. Update your code to match the following example:
216209

217210
```nodejs
218211
const credential = new DefaultAzureCredential();
@@ -238,7 +231,7 @@ Next, update your code to use passwordless connections.
238231
from azure.identity import DefaultAzureCredential
239232
```
240233

241-
1. Identify the locations in your code that create a `ServiceBusClient` object to connect to Azure Service Bus. Update your code to match the following example:
234+
1. Identify the code that creates a `ServiceBusClient` object to connect to Azure Service Bus. Update your code to match the following example:
242235

243236
```python
244237
credential = DefaultAzureCredential()
@@ -391,7 +384,7 @@ If you connected your services using the Service Connector you don't need to com
391384

392385
### [Azure CLI](#tab/assign-role-azure-cli)
393386

394-
To assign a role at the resource level using the Azure CLI, you first must retrieve the resource ID using the `az servicebus show` command. You can filter the output properties using the --query parameter.
387+
To assign a role at the resource level using the Azure CLI, you first must retrieve the resource ID using the `az servicebus show` command. You can filter the output properties using the `--query` parameter.
395388

396389
```azurecli
397390
az servicebus show \

0 commit comments

Comments
 (0)