Skip to content

Commit b44bdb8

Browse files
committed
Consolidating descriptions
1 parent 0d86cc2 commit b44bdb8

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

articles/communication-services/quickstarts/email/includes/send-email-java.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,17 @@ public class App
102102
```
103103

104104
### Creating the email client with authentication
105+
105106
There are a few different options available for authenticating an email client.
106107

107108
## [Connection String](#tab/connection-string)
108109

109-
#### Sync Client
110-
111-
To authenticate a client, you instantiate an `EmailClient` with your connection string. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string). You can also initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
110+
To authenticate a client, you instantiate an `EmailClient` or `EmailAsyncClient` with your connection string. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string). You can also initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
112111

113112
To instantiate a client, add the following code to the `main` method:
114113

114+
#### Sync Client
115+
115116
```java
116117
// You can get your connection string from your resource in the Azure portal.
117118
String connectionString = "endpoint=https://<resource-name>.communication.azure.com/;accesskey=<access-key>";
@@ -123,10 +124,6 @@ EmailClient emailClient = new EmailClientBuilder()
123124

124125
#### Async Client
125126

126-
To authenticate a client, you instantiate an `EmailAsyncClient` with your connection string. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string). You can also initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
127-
128-
To instantiate a client, add the following code to the `main` method:
129-
130127
```java
131128
// You can get your connection string from your resource in the Azure portal.
132129
String connectionString = "endpoint=https://<resource-name>.communication.azure.com/;accesskey=<access-key>";
@@ -140,12 +137,12 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
140137

141138
## [Microsoft Entra ID](#tab/entra-id)
142139

143-
#### Sync Client
144-
145140
A [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#defaultazurecredential) object must be passed to the `EmailClientBuilder` via the `credential()` method. An endpoint must also be set via the `endpoint()` method.
146141

147142
The `AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID`, and `AZURE_TENANT_ID` environment variables are needed to create a `DefaultAzureCredential` object.
148143

144+
#### Sync Client
145+
149146
```java
150147
// You can find your endpoint and access key from your resource in the Azure portal
151148
String endpoint = "https://<resource-name>.communication.azure.com/";
@@ -157,10 +154,6 @@ EmailClient emailClient = new EmailClientBuilder()
157154

158155
#### Async Client
159156

160-
A [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#defaultazurecredential) object must be passed to the `EmailClientBuilder` via the `credential()` method. An endpoint must also be set via the `endpoint()` method.
161-
162-
The `AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID`, and `AZURE_TENANT_ID` environment variables are needed to create a `DefaultAzureCredential` object.
163-
164157
```java
165158
// You can find your endpoint and access key from your resource in the Azure portal
166159
String endpoint = "https://<resource-name>.communication.azure.com/";
@@ -172,9 +165,10 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
172165

173166
#### [AzureKeyCredential](#tab/azure-key-credential)
174167

175-
## Sync Client
176168
Email clients can also be created and authenticated using the endpoint and Azure Key Credential acquired from an Azure Communication Resource in the [Azure portal](https://portal.azure.com/).
177169

170+
## Sync Client
171+
178172
```java
179173
String endpoint = "https://<resource-name>.communication.azure.com";
180174
AzureKeyCredential azureKeyCredential = new AzureKeyCredential("<access-key>");
@@ -186,8 +180,6 @@ EmailClient emailClient = new EmailClientBuilder()
186180

187181
## Async Client
188182

189-
Email clients can also be created and authenticated using the endpoint and Azure Key Credential acquired from an Azure Communication Resource in the [Azure portal](https://portal.azure.com/).
190-
191183
```java
192184
String endpoint = "https://<resource-name>.communication.azure.com";
193185
AzureKeyCredential azureKeyCredential = new AzureKeyCredential("<access-key>");
@@ -196,9 +188,9 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
196188
.credential(azureKeyCredential)
197189
.buildAsyncClient();
198190
```
191+
---
199192

200193
For simplicity, this quickstart uses connection strings, but in production environments, we recommend using [service principals](../../../quickstarts/identity/service-principal.md).
201-
---
202194

203195
## Basic email sending
204196

0 commit comments

Comments
 (0)