Skip to content

Commit a08b349

Browse files
author
Yogesh Mohanraj
committed
Adding documentation for adding sender usernames with Management SDK
1 parent e50e455 commit a08b349

File tree

5 files changed

+376
-0
lines changed

5 files changed

+376
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
---
13+
14+
# Quickstart: How to add and remove sender addresses in Azure Communication Services using the ACS Management Client Libraries
15+
16+
In this quick start, you will learn how to add and remove sender addresses in Azure Communication Services using the ACS Management Client Libraries.
17+
18+
::: zone pivot="programming-language-csharp"
19+
[!INCLUDE [Add sender addresses with .NET Management SDK](./includes/add-multiple-senders-net.md)]
20+
::: zone-end
21+
22+
::: zone pivot="programming-language-javascript"
23+
[!INCLUDE [Add sender addresses with Javascript Management SDK](./includes/add-multiple-senders-js.md)]
24+
::: zone-end
25+
26+
::: zone pivot="programming-language-java"
27+
[!INCLUDE [Add sender addresses with Java Management SDK](./includes/add-multiple-senders-java.md)]
28+
::: zone-end
29+
30+
::: zone pivot="programming-language-python"
31+
[!INCLUDE [Add sender addresses with Python Management SDK](./includes/add-multiple-senders-python.md)]
32+
::: zone-end
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 created and ready to provision the domains [Get started with Creating Email Communication Resource](../../quickstarts/email/create-email-communication-resource.md)
18+
- An [Azure Managed Domain](../../quickstarts/email/add-azure-managed-domains.md) or [Custom Domain](../../quickstarts/email/add-custom-verified-domains.md) provisioned and ready.
19+
- We will be using a [service principal for authentication](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). Set the values of the client ID, tenant ID and client secret of the AAD application as 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+
To initialize your client, intialize the environment variable `AZURE_SUBSCRIPTION_ID` with your subscription id before running the code sample.
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+
Update the code sample below with the resource group name, the email service name, and the domain name that you would like to add this username to. To add multiple sender usernames, you will need to repeat this code sample multiple times.
49+
50+
```java
51+
String resourceGroupName = "<your-resource-group-name>";
52+
String emailServiceName = "<your-email-service-name>";
53+
String domainName = "<your-domain-name>";
54+
55+
manager
56+
.senderUsernames()
57+
.define("contosoNewsAlerts")
58+
.withExistingDomain(resourceGroupName, emailServiceName, domainName)
59+
.withUsername("contosoNewsAlerts")
60+
.withDisplayName("Contoso News Alerts")
61+
.create();
62+
```
63+
64+
## Remove sender usernames
65+
66+
To delete the sender username, simply call the deleteWithResponse function on the client.
67+
68+
```java
69+
manager
70+
.senderUsernames()
71+
.deleteWithResponse(
72+
resourceGroupName,
73+
emailServiceName,
74+
domainName,
75+
"contosoNewsAlerts",
76+
com.azure.core.util.Context.NONE);
77+
```
78+
79+
## Next steps
80+
81+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../../quickstarts/email/create-email-communication-resource.md)
82+
83+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../../quickstarts/email/connect-email-communication-resource.md)
84+
85+
The following documents may be interesting to 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](../../quickstarts/email/add-custom-verified-domains.md)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 created and ready to provision the domains [Get started with Creating Email Communication Resource](../../quickstarts/email/create-email-communication-resource.md)
18+
- An [Azure Managed Domain](../../quickstarts/email/add-azure-managed-domains.md) or [Custom Domain](../../quickstarts/email/add-custom-verified-domains.md) provisioned and ready.
19+
- We will be using a [service principal for authentication](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). Set the values of the client ID, tenant ID and client secret of the AAD application as 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+
To initialize your client, replace the field in the sample code below with your subscription id.
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+
You can define the username you want to add in a parameters object. Update the code sample below with the resource group name, the email service name, and the domain name that you would like to add this username to. To add multiple sender usernames, you will need to repeat this code sample multiple times.
45+
46+
```javascript
47+
const resourceGroupName = "<your-resource-group-name>";
48+
const emailServiceName = "<your-email-service-name>";
49+
const domainName = "<your-domain-name>";
50+
51+
const parameters = {
52+
displayName: "Contoso News Alerts",
53+
username: "contosoNewsAlerts",
54+
};
55+
56+
await mgmtClient.senderUsernames.createOrUpdate(
57+
resourceGroupName,
58+
emailServiceName,
59+
domainName,
60+
"contosoNewsAlerts",
61+
parameters
62+
);
63+
```
64+
65+
## Remove sender usernames
66+
67+
To delete the sender username, simply call the delete function on the client.
68+
69+
```javascript
70+
await mgmtClient.senderUsernames.delete(
71+
resourceGroupName,
72+
emailServiceName,
73+
domainName,
74+
"contosoNewsAlerts"
75+
);
76+
```
77+
78+
## Next steps
79+
80+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../../quickstarts/email/create-email-communication-resource.md)
81+
82+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../../quickstarts/email/connect-email-communication-resource.md)
83+
84+
The following documents may be interesting to you:
85+
86+
- Familiarize yourself with the [Email client library](../../concepts/email/sdk-features.md)
87+
- How to send emails with custom verified domains?[Add custom domains](../../quickstarts/email/add-custom-verified-domains.md)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 created and ready to provision the domains [Get started with Creating Email Communication Resource](../../quickstarts/email/create-email-communication-resource.md)
18+
- An [Azure Managed Domain](../../quickstarts/email/add-azure-managed-domains.md) or [Custom Domain](../../quickstarts/email/add-custom-verified-domains.md) provisioned and ready.
19+
- We will be using a [service principal for authentication](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). Set the values of the client ID, tenant ID and client secret of the AAD application as 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+
To initialize your client, intialize the environment variable `AZURE_SUBSCRIPTION_ID` with your subscription id before running the code sample.
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+
You can define the username you want to add in a SenderUsernameResourceData object. Update the code sample below with the subscription id, resource group name, the email service name, and the domain name that you would like to add this username to. To add multiple sender usernames, you will need to repeat this code sample multiple times.
46+
47+
```csharp
48+
string subscriptionId = "<your-subscription-id>";
49+
string resourceGroupName = "<your-resource-group-name>";
50+
string emailServiceName = "<your-email-service-name>";
51+
string domainName = "<your-domain-name>";
52+
53+
ResourceIdentifier senderUsernameResourceId = SenderUsernameResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, emailServiceName, domainName, "contosoNewsAlerts");
54+
SenderUsernameResource senderUsernameResource = client.GetSenderUsernameResource(senderUsernameResourceId);
55+
56+
SenderUsernameResourceData data = new SenderUsernameResourceData()
57+
{
58+
Username = "contosoNewsAlerts",
59+
DisplayName = "Contoso News Alerts",
60+
};
61+
62+
await senderUsernameResource.UpdateAsync(WaitUntil.Completed, data);
63+
```
64+
65+
## Remove sender usernames
66+
67+
To delete the sender username, simply call the DeleteAsync function on the senderUsernameResource.
68+
69+
```python
70+
await senderUsernameResource.DeleteAsync(WaitUntil.Completed);
71+
```
72+
73+
## Next steps
74+
75+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../../quickstarts/email/create-email-communication-resource.md)
76+
77+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../../quickstarts/email/connect-email-communication-resource.md)
78+
79+
The following documents may be interesting to you:
80+
81+
- Familiarize yourself with the [Email client library](../../concepts/email/sdk-features.md)
82+
- How to send emails with custom verified domains?[Add custom domains](../../quickstarts/email/add-custom-verified-domains.md)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 created and ready to provision the domains [Get started with Creating Email Communication Resource](../../quickstarts/email/create-email-communication-resource.md)
18+
- An [Azure Managed Domain](../../quickstarts/email/add-azure-managed-domains.md) or [Custom Domain](../../quickstarts/email/add-custom-verified-domains.md) provisioned and ready.
19+
- We will be using a [service principal for authentication](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). Set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_CLIENT_SECRET.
20+
21+
## Install the required packages
22+
23+
```console
24+
pip install azure-mgmt-communication
25+
pip install azure-identity
26+
```
27+
28+
## Initialize the management client
29+
30+
To initialize your client, replace the field in the sample code below with your subscription id.
31+
32+
```python
33+
from azure.mgmt.communication import CommunicationServiceManagementClient
34+
from azure.identity import AzureCliCredential
35+
36+
credential = DefaultAzureCredential()
37+
subscription_id = "<your-subscription-id>"
38+
39+
mgmt_client = CommunicationServiceManagementClient(credential, subscription_id)
40+
```
41+
42+
## Add sender usernames
43+
44+
You can define the username you want to add in a parameters object. Update the code sample below with the resource group name, the email service name, and the domain name that you would like to add this username to. To add multiple sender usernames, you will need to repeat this code sample multiple times.
45+
46+
```python
47+
resource_group_name = "<your-resource-group-name>"
48+
email_service_name = "<your-email-service-name>"
49+
domain_name = "<your-domain-name>"
50+
51+
parameters = {
52+
"username": "contosoNewsAlerts",
53+
"displayName": "Contoso News Alerts",
54+
}
55+
56+
mgmt_client.sender_usernames.create_or_update(
57+
resource_group_name,
58+
email_service_name,
59+
domain_name,
60+
"contosoNewsAlerts",
61+
parameters
62+
)
63+
```
64+
65+
## Remove sender usernames
66+
67+
To delete the sender username, simply call the delete function on the client.
68+
69+
```python
70+
mgmt_client.sender_usernames.delete(
71+
resource_group_name,
72+
email_service_name,
73+
domain_name,
74+
"contosoNewsAlerts"
75+
)
76+
```
77+
78+
## Next steps
79+
80+
* [Get started with create and manage Email Communication Service in Azure Communication Service](../../quickstarts/email/create-email-communication-resource.md)
81+
82+
* [Get started by connecting Email Communication Service with a Azure Communication Service resource](../../quickstarts/email/connect-email-communication-resource.md)
83+
84+
The following documents may be interesting to you:
85+
86+
- Familiarize yourself with the [Email client library](../../concepts/email/sdk-features.md)
87+
- How to send emails with custom verified domains?[Add custom domains](../../quickstarts/email/add-custom-verified-domains.md)

0 commit comments

Comments
 (0)