You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/email/includes/send-email-java.md
+9-17Lines changed: 9 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,16 +102,17 @@ public class App
102
102
```
103
103
104
104
### Creating the email client with authentication
105
+
105
106
There are a few different options available for authenticating an email client.
106
107
107
108
## [Connection String](#tab/connection-string)
108
109
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.
112
111
113
112
To instantiate a client, add the following code to the `main` method:
114
113
114
+
#### Sync Client
115
+
115
116
```java
116
117
// You can get your connection string from your resource in the Azure portal.
@@ -123,10 +124,6 @@ EmailClient emailClient = new EmailClientBuilder()
123
124
124
125
#### Async Client
125
126
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
-
130
127
```java
131
128
// You can get your connection string from your resource in the Azure portal.
@@ -140,12 +137,12 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
140
137
141
138
## [Microsoft Entra ID](#tab/entra-id)
142
139
143
-
#### Sync Client
144
-
145
140
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.
146
141
147
142
The `AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID`, and `AZURE_TENANT_ID` environment variables are needed to create a `DefaultAzureCredential` object.
148
143
144
+
#### Sync Client
145
+
149
146
```java
150
147
// You can find your endpoint and access key from your resource in the Azure portal
@@ -157,10 +154,6 @@ EmailClient emailClient = new EmailClientBuilder()
157
154
158
155
#### Async Client
159
156
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
-
164
157
```java
165
158
// You can find your endpoint and access key from your resource in the Azure portal
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/).
@@ -186,8 +180,6 @@ EmailClient emailClient = new EmailClientBuilder()
186
180
187
181
## Async Client
188
182
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/).
@@ -196,9 +188,9 @@ EmailAsyncClient emailClient = new EmailClientBuilder()
196
188
.credential(azureKeyCredential)
197
189
.buildAsyncClient();
198
190
```
191
+
---
199
192
200
193
For simplicity, this quickstart uses connection strings, but in production environments, we recommend using [service principals](../../../quickstarts/identity/service-principal.md).
0 commit comments