Skip to content

Commit efdf24a

Browse files
committed
Fixing tabs for auth
1 parent 60a25a3 commit efdf24a

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,15 @@ public class App
101101
}
102102
```
103103

104-
### Creating the email client with authentication
104+
## Creating the email client with authentication
105105

106106
There are a few different options available for authenticating an email client.
107107

108-
## [Connection String](#tab/connection-string)
108+
#### [Connection String](#tab/connection-string)
109109

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.
110+
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.
111111

112-
To instantiate a client, add the following code to the `main` method:
113-
114-
#### Sync Client
112+
To instantiate a synchronous client, add the following code to the `main` method:
115113

116114
```java
117115
// You can get your connection string from your resource in the Azure portal.
@@ -122,7 +120,7 @@ EmailClient emailClient = new EmailClientBuilder()
122120
.buildClient();
123121
```
124122

125-
#### Async Client
123+
To instantiate an asynchronous client, add the following code to the `main` method:
126124

127125
```java
128126
// You can get your connection string from your resource in the Azure portal.
@@ -133,13 +131,15 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
133131
.buildAsyncClient();
134132
```
135133

136-
## [Microsoft Entra ID](#tab/entra-id)
134+
<a name='azure-active-directory'></a>
135+
136+
#### [Microsoft Entra ID](#tab/aad)
137137

138138
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.
139139

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

142-
#### Sync Client
142+
To instantiate a synchronous client, add the following code to the `main` method:
143143

144144
```java
145145
// You can find your endpoint and access key from your resource in the Azure portal
@@ -150,7 +150,7 @@ EmailClient emailClient = new EmailClientBuilder()
150150
.buildClient();
151151
```
152152

153-
#### Async Client
153+
To instantiate an asynchronous client, add the following code to the `main` method:
154154

155155
```java
156156
// You can find your endpoint and access key from your resource in the Azure portal
@@ -161,11 +161,11 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
161161
.buildAsyncClient();
162162
```
163163

164-
## [AzureKeyCredential](#tab/azure-key-credential)
164+
#### [AzureKeyCredential](#tab/azurekeycredential)
165165

166166
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/).
167167

168-
#### Sync Client
168+
To instantiate a synchronous client, add the following code to the `main` method:
169169

170170
```java
171171
String endpoint = "https://<resource-name>.communication.azure.com";
@@ -176,20 +176,23 @@ EmailClient emailClient = new EmailClientBuilder()
176176
.buildClient();
177177
```
178178

179-
#### Async Client
179+
To instantiate an asynchronous client, add the following code to the `main` method:
180180

181181
```java
182182
String endpoint = "https://<resource-name>.communication.azure.com";
183183
AzureKeyCredential azureKeyCredential = new AzureKeyCredential("<access-key>");
184-
EmailAsyncClient emailClient = new EmailClientBuilder()
184+
EmailClient emailClient = new EmailClientBuilder()
185185
.endpoint(endpoint)
186186
.credential(azureKeyCredential)
187-
.buildAsyncClient();
187+
.buildClient();
188188
```
189+
189190
---
190191

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

194+
195+
193196
## Basic email sending
194197

195198
An email message can be crafted using the `EmailMessage` object in the SDK.
@@ -274,6 +277,7 @@ emailClient.beginSend(emailMessage).subscribe(
274277
}
275278
);
276279
```
280+
277281
---
278282

279283
### Run the code

0 commit comments

Comments
 (0)