Skip to content

Commit c0c89aa

Browse files
Merge pull request #235217 from yogeshmo/email/adding-sender-username-mgmt-docs
Adding documentation for adding sender usernames with Management SDK
2 parents 81f6774 + 355708e commit c0c89aa

File tree

6 files changed

+403
-0
lines changed

6 files changed

+403
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: How to add and remove sender addresses in Azure Communication Services using the ACS Management Client Libraries
3+
titleSuffix: An Azure Communication Services quick start guide.
4+
description: Learn about adding and removing sender addresses in Azure Communication Services using the ACS Management Client Libraries
5+
author: yogeshmo
6+
manager: koagbakp
7+
services: azure-communication-services
8+
ms.author: ymohanraj
9+
ms.date: 04/19/2023
10+
ms.topic: quickstart
11+
ms.service: azure-communication-services
12+
zone_pivot_groups: acs-js-csharp-java-python
13+
---
14+
15+
# Quickstart: How to add and remove sender addresses in Azure Communication Services using the ACS Management Client Libraries
16+
17+
In this quick start, you will learn how to add and remove sender addresses in Azure Communication Services using the ACS Management Client Libraries.
18+
19+
::: zone pivot="programming-language-csharp"
20+
[!INCLUDE [Add sender addresses with .NET Management SDK](./includes/add-multiple-senders-net.md)]
21+
::: zone-end
22+
23+
::: zone pivot="programming-language-javascript"
24+
[!INCLUDE [Add sender addresses with Javascript Management SDK](./includes/add-multiple-senders-js.md)]
25+
::: zone-end
26+
27+
::: zone pivot="programming-language-java"
28+
[!INCLUDE [Add sender addresses with Java Management SDK](./includes/add-multiple-senders-java.md)]
29+
::: zone-end
30+
31+
::: zone pivot="programming-language-python"
32+
[!INCLUDE [Add sender addresses with Python Management SDK](./includes/add-multiple-senders-python.md)]
33+
::: zone-end
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: include file
3+
description: include file
4+
author: yogeshmo
5+
manager: koagbakp
6+
services: azure-communication-services
7+
ms.author: yogeshmo
8+
ms.date: 04/19/2023
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.custom: mode-other
12+
---
13+
14+
## Prerequisites
15+
16+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/dotnet/).
17+
- An Azure Email Communication Services Resource ready to provision domains. [Get started creating an Email Communication Resource](../create-email-communication-resource.md).
18+
- An [Azure Managed Domain](../add-azure-managed-domains.md) or [Custom Domain](../add-custom-verified-domains.md) provisioned and ready to send emails.
19+
- We are using a [service principal for authentication](../../../../active-directory/develop/howto-create-service-principal-portal.md). Set the values of the client ID, tenant ID and client secret of the AAD application as the following environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET`.
20+
21+
## Install the required packages
22+
23+
Add the following dependency to your `pom.xml`.
24+
25+
```
26+
<dependency>
27+
<groupId>com.azure.resourcemanager</groupId>
28+
<artifactId>azure-resourcemanager-communication</artifactId>
29+
<version>2.0.0</version>
30+
</dependency>
31+
```
32+
33+
## Initialize the management client
34+
35+
Set the environment variable `AZURE_SUBSCRIPTION_ID` with the subscription ID of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
36+
37+
```java
38+
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
39+
TokenCredential credential = new DefaultAzureCredentialBuilder()
40+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
41+
.build();
42+
CommunicationManager manager = CommunicationManager
43+
.authenticate(credential, profile);
44+
```
45+
46+
## Add sender usernames
47+
48+
When an Azure Managed Domain resource is provisioned, the MailFrom address defaults to [email protected]. If you have configured a custom domain such as "notification.azurecommtest.net" the MailFrom address defaults to "[email protected]".
49+
50+
The username is the user alias that is used in the MailFrom address. For example, the username in the MailFrom address `[email protected]` would be `contosoNewsAlerts`. You can add extra sender usernames, which can also be configured with a more user friendly display name. In our example, the display name is `Contoso News Alerts`.
51+
52+
Update the code sample with the resource group name, the email service name, and the domain name that you would like to add this username to. This information can be found in portal by navigating to the domains resource you created when setting up the prerequisites. The title of the resource is `<your-email-service-name>/<your-domain-name>`. The resource group name can be found in the Essentials sections in the domain resource overview.
53+
54+
To add multiple sender usernames, you need to repeat this code sample multiple times.
55+
56+
```java
57+
String resourceGroupName = "<your-resource-group-name>";
58+
String emailServiceName = "<your-email-service-name>";
59+
String domainName = "<your-domain-name>";
60+
61+
manager
62+
.senderUsernames()
63+
.define("contosoNewsAlerts")
64+
.withExistingDomain(resourceGroupName, emailServiceName, domainName)
65+
.withUsername("contosoNewsAlerts")
66+
.withDisplayName("Contoso News Alerts")
67+
.create();
68+
```
69+
70+
## Remove sender usernames
71+
72+
To delete the sender username, call the deleteWithResponse function on the client.
73+
74+
```java
75+
manager
76+
.senderUsernames()
77+
.deleteWithResponse(
78+
resourceGroupName,
79+
emailServiceName,
80+
domainName,
81+
"contosoNewsAlerts",
82+
com.azure.core.util.Context.NONE);
83+
```
84+
85+
## Next steps
86+
87+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../create-email-communication-resource.md)
88+
89+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../connect-email-communication-resource.md)
90+
91+
The following documents may interest you:
92+
93+
- Familiarize yourself with the [Email client library](../../../concepts/email/sdk-features.md)
94+
- How to send emails with custom verified domains?[Add custom domains](../add-custom-verified-domains.md)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: include file
3+
description: include file
4+
author: yogeshmo
5+
manager: koagbakp
6+
services: azure-communication-services
7+
ms.author: yogeshmo
8+
ms.date: 04/19/2023
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.custom: mode-other
12+
---
13+
14+
## Prerequisites
15+
16+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/dotnet/).
17+
- An Azure Email Communication Services Resource ready to provision domains. [Get started creating an Email Communication Resource](../create-email-communication-resource.md).
18+
- An [Azure Managed Domain](../add-azure-managed-domains.md) or [Custom Domain](../add-custom-verified-domains.md) provisioned and ready to send emails.
19+
- We are using a [service principal for authentication](../../../../active-directory/develop/howto-create-service-principal-portal.md). Set the values of the client ID, tenant ID and client secret of the AAD application as the following environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET`.
20+
21+
## Install the required packages
22+
23+
```console
24+
npm install @azure/arm-communication
25+
npm install @azure/identity
26+
```
27+
28+
## Initialize the management client
29+
30+
Replace the field in the sample code with the subscription ID of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
31+
32+
```javascript
33+
const { CommunicationServiceManagementClient } = require("@azure/arm-communication");
34+
const { DefaultAzureCredential } = require("@azure/identity");
35+
36+
const credential = new DefaultAzureCredential();
37+
const subscriptionId = "<your-subscription-id>";
38+
39+
mgmtClient = new CommunicationServiceManagementClient(credential, subscriptionId);
40+
```
41+
42+
## Add sender usernames
43+
44+
When an Azure Managed Domain resource is provisioned, the MailFrom address defaults to [email protected]. If you have configured a custom domain such as "notification.azurecommtest.net" the MailFrom address defaults to "[email protected]".
45+
46+
The username is the user alias that is used in the MailFrom address. For example, the username in the MailFrom address `[email protected]` would be `contosoNewsAlerts`. You can add extra sender usernames, which can also be configured with a more user friendly display name. In our example, the display name is `Contoso News Alerts`.
47+
48+
Update the code sample with the resource group name, the email service name, and the domain name that you would like to add this username to. This information can be found in portal by navigating to the domains resource you created when setting up the prerequisites. The title of the resource is `<your-email-service-name>/<your-domain-name>`. The resource group name can be found in the Essentials sections in the domain resource overview.
49+
50+
To add multiple sender usernames, you need to repeat this code sample multiple times.
51+
52+
```javascript
53+
const resourceGroupName = "<your-resource-group-name>";
54+
const emailServiceName = "<your-email-service-name>";
55+
const domainName = "<your-domain-name>";
56+
57+
const parameters = {
58+
displayName: "Contoso News Alerts",
59+
username: "contosoNewsAlerts",
60+
};
61+
62+
await mgmtClient.senderUsernames.createOrUpdate(
63+
resourceGroupName,
64+
emailServiceName,
65+
domainName,
66+
"contosoNewsAlerts",
67+
parameters
68+
);
69+
```
70+
71+
## Remove sender usernames
72+
73+
To delete the sender username, call the delete function on the client.
74+
75+
```javascript
76+
await mgmtClient.senderUsernames.delete(
77+
resourceGroupName,
78+
emailServiceName,
79+
domainName,
80+
"contosoNewsAlerts"
81+
);
82+
```
83+
84+
## Next steps
85+
86+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../create-email-communication-resource.md)
87+
88+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../connect-email-communication-resource.md)
89+
90+
The following documents may interest you:
91+
92+
- Familiarize yourself with the [Email client library](../../../concepts/email/sdk-features.md)
93+
- How to send emails with custom verified domains?[Add custom domains](../add-custom-verified-domains.md)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: include file
3+
description: include file
4+
author: yogeshmo
5+
manager: koagbakp
6+
services: azure-communication-services
7+
ms.author: yogeshmo
8+
ms.date: 04/19/2023
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.custom: mode-other
12+
---
13+
14+
## Prerequisites
15+
16+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/dotnet/).
17+
- An Azure Email Communication Services Resource ready to provision domains. [Get started creating an Email Communication Resource](../create-email-communication-resource.md).
18+
- An [Azure Managed Domain](../add-azure-managed-domains.md) or [Custom Domain](../add-custom-verified-domains.md) provisioned and ready to send emails.
19+
- We are using a [service principal for authentication](../../../../active-directory/develop/howto-create-service-principal-portal.md). Set the values of the client ID, tenant ID and client secret of the AAD application as the following environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET`.
20+
21+
## Install the required packages
22+
23+
```console
24+
dotnet add package Azure.ResourceManager.Communication
25+
```
26+
27+
## Initialize the management client
28+
29+
Set the environment variable `AZURE_SUBSCRIPTION_ID` with the subscription id of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
30+
31+
```csharp
32+
using System;
33+
using System.Threading.Tasks;
34+
using Azure.Core;
35+
using Azure.Identity;
36+
using Azure.ResourceManager;
37+
using Azure.ResourceManager.Compute;
38+
using Azure.ResourceManager.Resources;
39+
40+
ArmClient client = new ArmClient(new DefaultAzureCredential());
41+
```
42+
43+
## Add sender usernames
44+
45+
When an Azure Managed Domain resource is provisioned, the MailFrom address defaults to [email protected]. If you have configured a custom domain such as "notification.azurecommtest.net" the MailFrom address defaults to "[email protected]".
46+
47+
The username is the user alias that is used in the MailFrom address. For example, the username in the MailFrom address `[email protected]` would be `contosoNewsAlerts`. You can add extra sender usernames, which can also be configured with a more user friendly display name. In our example, the display name is `Contoso News Alerts`.
48+
49+
Update the code sample with the resource group name, the email service name, and the domain name that you would like to add this username to. This information can be found in portal by navigating to the domains resource you created when setting up the prerequisites. The title of the resource is `<your-email-service-name>/<your-domain-name>`. The resource group name and subscription ID can be found in the Essentials sections in the domain resource overview.
50+
51+
To add multiple sender usernames, you need to repeat this code sample multiple times.
52+
53+
```csharp
54+
string subscriptionId = "<your-subscription-id>";
55+
string resourceGroupName = "<your-resource-group-name>";
56+
string emailServiceName = "<your-email-service-name>";
57+
string domainName = "<your-domain-name>";
58+
59+
ResourceIdentifier senderUsernameResourceId = SenderUsernameResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, emailServiceName, domainName, "contosoNewsAlerts");
60+
SenderUsernameResource senderUsernameResource = client.GetSenderUsernameResource(senderUsernameResourceId);
61+
62+
SenderUsernameResourceData data = new SenderUsernameResourceData()
63+
{
64+
Username = "contosoNewsAlerts",
65+
DisplayName = "Contoso News Alerts",
66+
};
67+
68+
await senderUsernameResource.UpdateAsync(WaitUntil.Completed, data);
69+
```
70+
71+
## Remove sender usernames
72+
73+
To delete the sender username, call the DeleteAsync function on the senderUsernameResource.
74+
75+
```python
76+
await senderUsernameResource.DeleteAsync(WaitUntil.Completed);
77+
```
78+
79+
## Next steps
80+
81+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../create-email-communication-resource.md)
82+
83+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../connect-email-communication-resource.md)
84+
85+
The following documents may interest you:
86+
87+
- Familiarize yourself with the [Email client library](../../../concepts/email/sdk-features.md)
88+
- How to send emails with custom verified domains?[Add custom domains](../add-custom-verified-domains.md)

0 commit comments

Comments
 (0)