Skip to content

Commit 9de88cc

Browse files
authored
Merge pull request #226567 from mayssamm/main
[Communication] add azure-cli quick start for email
2 parents 8581e5e + 2b0af16 commit 9de88cc

File tree

4 files changed

+140
-9
lines changed

4 files changed

+140
-9
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: include file
3+
description: include file
4+
author: mayssamm
5+
manager: ankita
6+
services: azure-communication-services
7+
ms.author: mayssamm
8+
ms.date: 02/03/2023
9+
ms.topic: include
10+
ms.service: azure-communication-services
11+
ms.custom: include files
12+
---
13+
14+
Get started with Azure Communication Services by using the Azure CLI communication extension to send Email messages.
15+
16+
Completing this quick start incurs a small cost of a few USD cents or less in your Azure account.
17+
18+
## Prerequisites
19+
20+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
21+
- An Azure Email Communication Services resource created and ready with a provisioned domain. [Get started with creating an Email Communication Resource](../create-email-communication-resource.md).
22+
- An active Azure Communication Services resource connected to an Email Domain and its connection string. [Get started by connecting an Email Communication Resource with a Azure Communication Resource](../connect-email-communication-resource.md).
23+
- The latest [Azure CLI](/cli/azure/install-azure-cli-windows?tabs=azure-cli).
24+
25+
### Prerequisite check
26+
- In a terminal or command window, run the `az --version` command to check that Azure CLI and the communication extension are installed.
27+
- To view the domains verified with your Email Communication Services resource, sign in to the [Azure portal](https://portal.azure.com/). Locate your Email Communication Services resource and open the **Provision domains** tab from the left navigation pane.
28+
29+
## Setting up
30+
### Add the extension
31+
Add the Azure Communication Services extension for Azure CLI by using the `az extension` command.
32+
33+
```azurecli-interactive
34+
az extension add --name communication
35+
```
36+
37+
### Sign in to Azure CLI
38+
You'll need to [sign in to Azure CLI](/cli/azure/authenticate-azure-cli). You can sign in running the ```az login``` command from the terminal and providing your credentials.
39+
40+
41+
### Store your connection string in an environment variable
42+
43+
You can configure the `AZURE_COMMUNICATION_CONNECTION_STRING` environment variable to use Azure CLI keys operations without having to use `--connection_string` to pass in the connection string. To configure an environment variable, open a console window and select your operating system from the below tabs. Replace `<connectionString>` with your actual connection string.
44+
45+
##### [Windows](#tab/windows)
46+
47+
```console
48+
setx AZURE_COMMUNICATION_STRING "<yourConnectionString>"
49+
```
50+
51+
After you add the environment variable, you may need to restart any running programs that will need to read the environment variable, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before running the example.
52+
53+
##### [macOS](#tab/unix)
54+
55+
Edit your **`.zshrc`**, and add the environment variable:
56+
57+
```bash
58+
export AZURE_COMMUNICATION_STRING="<connectionString>"
59+
```
60+
61+
After you add the environment variable, run `source ~/.zshrc` from your console window to make the changes effective. If you created the environment variable with your IDE open, you may need to close and reopen the editor, IDE, or shell in order to access the variable.
62+
63+
##### [Linux](#tab/linux)
64+
65+
Edit your **`.bash_profile`**, and add the environment variable:
66+
67+
```bash
68+
export AZURE_COMMUNICATION_STRING="<connectionString>"
69+
```
70+
71+
After you add the environment variable, run `source ~/.bash_profile` from your console window to make the changes effective. If you created the environment variable with your IDE open, you may need to close and reopen the editor, IDE, or shell in order to access the variable.
72+
73+
---
74+
75+
## Send an email message
76+
77+
```azurecli-interactive
78+
az communication email send
79+
--connection-string "yourConnectionString"
80+
--sender "<[email protected]>"
81+
82+
--subject "Welcome to Azure Communication Services Email" --text "This email message is sent from Azure Communication Services Email using Azure CLI."
83+
```
84+
85+
Make these replacements in the code:
86+
87+
- Replace `<yourConnectionString>` with your connection string.
88+
- Replace "<[email protected]>" with the email address you would like to send a message to.
89+
- Replace "<[email protected]>" with the MailFrom address of your verified domain.
90+
91+
To track the status of the email delivery, you'll need the `messageId` from the response.
92+
93+
### Optional parameters
94+
95+
The following optional parameters are available in Azure CLI.
96+
97+
- `--html` can be used instead of `--text` for html email body.
98+
99+
- `--importance` sets the importance type for the email. Known values are: high, normal, and low. Default is normal.
100+
101+
- `--cc` sets carbon copy email addresses.
102+
103+
- `--bcc` sets blind carbon copy email addresses.
104+
105+
- `--reply-to` sets Reply-To email address.
106+
107+
- `--disable-tracking` indicates whether user engagement tracking should be disabled for this request.
108+
109+
- `--attachments` sets the list of email attachments.
110+
111+
- `--attachment-types` sets the list of email attachment types, in the same order of attachments.
112+
113+
Also, you can use a list of recipients with `--to`, similar to `--cc` and `--bcc`.
114+
115+
116+
## Get the status of the email delivery
117+
118+
We can keep checking the email delivery status until the status is `OutForDelivery`.
119+
120+
```azurecli-interactive
121+
az communication email status get --message-id "\<messageId\>"
122+
```
123+
124+
- Replace "\<messageId\>" with the messageId from the response of the send request.
125+
126+
[!INCLUDE [Email Message Status](./email-message-status.md)]
127+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pip install azure-communication-email
6363

6464
## Object model
6565

66-
The following classes and interfaces handle some of the major features of the Azure Communication Services SMS SDK for Python.
66+
The following classes and interfaces handle some of the major features of the Azure Communication Services Email SDK for Python.
6767

6868
| Name | Description |
6969
| ---- |-------------|

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.date: 04/15/2022
1010
ms.topic: quickstart
1111
ms.service: azure-communication-services
1212
ms.custom: private_preview, event-tier1-build-2022
13-
zone_pivot_groups: acs-js-csharp-java-python
13+
zone_pivot_groups: acs-azcli-js-csharp-java-python
1414
---
1515

1616
# Quickstart: How to send an email using Azure Communication Service
@@ -19,6 +19,10 @@ zone_pivot_groups: acs-js-csharp-java-python
1919

2020
In this quick start, you'll learn about how to send email using our Email SDKs.
2121

22+
::: zone pivot="platform-azcli"
23+
[!INCLUDE [Send email with Azure CLI](./includes/send-email-az-cli.md)]
24+
::: zone-end
25+
2226
::: zone pivot="programming-language-csharp"
2327
[!INCLUDE [Send email with .NET SDK](./includes/send-email-net.md)]
2428
::: zone-end

articles/communication-services/quickstarts/rooms/includes/rooms-quickstart-az-cli.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ az extension add --name communication
3232
You'll need to [sign in to Azure CLI](/cli/azure/authenticate-azure-cli). You can sign in running the ```az login``` command from the terminal and providing your credentials.
3333

3434

35-
### Store your connection string in an envrionment variable
35+
### Store your connection string in an environment variable
3636

3737
You can configure the `AZURE_COMMUNICATION_CONNECTION_STRING` environment variable to use Azure CLI keys operations without having to use `--connection_string` to pass in the connection string. To configure an environment variable, open a console window and select your operating system from the below tabs. Replace `<connectionString>` with your actual connection string.
3838

@@ -42,7 +42,7 @@ You can configure the `AZURE_COMMUNICATION_CONNECTION_STRING` environment variab
4242
setx AZURE_COMMUNICATION_STRING "<yourConnectionString>"
4343
```
4444

45-
After you add the environment variable, you may need to restart any running programs that will need to read the environment variable, including the console window. For example, if you are using Visual Studio as your editor, restart Visual Studio before running the example.
45+
After you add the environment variable, you may need to restart any running programs that will need to read the environment variable, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before running the example.
4646

4747
##### [macOS](#tab/unix)
4848

@@ -56,7 +56,7 @@ After you add the environment variable, run `source ~/.zshrc` from your console
5656

5757
##### [Linux](#tab/linux)
5858

59-
Edit your **`.bash_profile`**, and add the environment vairable:
59+
Edit your **`.bash_profile`**, and add the environment variable:
6060

6161
```bash
6262
export AZURE_COMMUNICATION_STRING="<connectionString>"
@@ -82,7 +82,7 @@ az communication rooms create --presenter-participants "<participantId>" --consu
8282
- Use `<validFrom>` optionally to specify the timestamp when the room is open for joining, in ISO8601 format, ex: 2022-07-14T10:21.
8383
- Use `<validUntil>` optionally to specify the timestamp when the room can no longer be joined, in ISO8601 format, ex: 2022-07-14T10:21.
8484

85-
If you have stored the connection string in environment variables as stated above, you won't need to pass them to the command.
85+
If you've stored the connection string in environment variables as stated above, you won't need to pass them to the command.
8686

8787
```azurecli-interactive
8888
az communication rooms create
@@ -93,7 +93,7 @@ az communication rooms create
9393

9494
### Get the rooms
9595

96-
The `rooms get` command returns the attributes of an exisiting room.
96+
The `rooms get` command returns the attributes of an existing room.
9797

9898
```azurecli-interactive
9999
az communication rooms get --room "<roomId>"
@@ -129,8 +129,8 @@ You can update the timestamp of a room. Before calling the `room update` command
129129
az communication rooms update --validFrom "<validFrom>" --validUntil "<validUntil>" --room "<roomId>"
130130
```
131131

132-
- Replace `<validFrom>` with the timestamp in ISO8601 format, ex: 2022-07-14T10:21, to specify when the room is open for joining. Should be used together with --valid-until.
133-
- Replace `<validUntil>` with the timestamp in ISO8601 format, ex: 2022-07-14T10:21, to specify when the room can no longer be joined. Should be used together with --valid-from.
132+
- Replace `<validFrom>` with the timestamp in ISO8601 format, ex: 2022-07-14T10:21, to specify when the room is open for joining. Should be used together with `--valid-until`.
133+
- Replace `<validUntil>` with the timestamp in ISO8601 format, ex: 2022-07-14T10:21, to specify when the room can no longer be joined. Should be used together with `--valid-from`.
134134
- Replace `<roomId>` with your room ID.
135135

136136

0 commit comments

Comments
 (0)