|
| 1 | +--- |
| 2 | +title: Email action within Remote Monitoring - Azure | Microsoft Docs |
| 3 | +description: This how-to guide shows you how to add an email action to a new or existing rule. |
| 4 | +author: asdonald |
| 5 | +manager: hegate |
| 6 | +ms.author: asdonald |
| 7 | +ms.service: iot-accelerators |
| 8 | +services: iot-accelerators |
| 9 | +ms.date: 11/12/2018 |
| 10 | +ms.topic: conceptual |
| 11 | + |
| 12 | +# As a developer, I want to add email as an action to a new or existing rule within my Remote Monitoring solution. |
| 13 | +--- |
| 14 | + |
| 15 | +# Add an email action |
| 16 | + |
| 17 | +Email actions help make sure you never miss alerts. You can add an email action to an existing rule, or when you create a new rule. |
| 18 | + |
| 19 | +[!INCLUDE [iot-accelerators-tutorial-prereqs](../../includes/iot-accelerators-tutorial-prereqs.md)] |
| 20 | + |
| 21 | +To create or modify a rule, you must be an [**Administrator**, or have the correct permissions](iot-accelerators-remote-monitoring-rbac.md). |
| 22 | + |
| 23 | +## Edit an existing rule |
| 24 | + |
| 25 | +Follow these steps to add an email action to an existing rule: |
| 26 | + |
| 27 | +1. Navigate to your Remote Monitoring solution. |
| 28 | + |
| 29 | +1. From the **Dashboard**, navigate to the **Rules** page: |
| 30 | + |
| 31 | +  |
| 32 | + |
| 33 | +1. Click the checkbox next to the existing rule to modify, and then click **Edit** at the top. An editable **Rule** panel appears. |
| 34 | + |
| 35 | +1. In the **Action** section, toggle **Email enabled** to **On**. |
| 36 | + |
| 37 | +1. The first time you enable an email action in the solution accelerator, you must [sign in to Outlook](#outlook). |
| 38 | + |
| 39 | +1. Enter an email address into the recipient box and press the **Enter** key for each email address to add: |
| 40 | + |
| 41 | +  |
| 42 | + |
| 43 | +1. Enter a subject for the email. |
| 44 | + |
| 45 | +1. Enter any additional notes for the email recipients as plain text. You can use HTML formatting if you [edit the email template](#htmledit). |
| 46 | + |
| 47 | +1. Make sure that the **Rule Status** is set to **Enabled**. |
| 48 | + |
| 49 | +1. Click **Apply**. |
| 50 | + |
| 51 | +## Create a new rule |
| 52 | + |
| 53 | +Follow these steps to add an email action when you create a new rule: |
| 54 | + |
| 55 | +1. Navigate to your Remote Monitoring solution. |
| 56 | + |
| 57 | +1. From the **Dashboard**, navigate to the **Rules** page: |
| 58 | + |
| 59 | +  |
| 60 | + |
| 61 | +1. Follow the steps in the [create a rule section](iot-accelerators-remote-monitoring-automate.md#create-a-rule). The follow the steps in the [create an advanced rule](iot-accelerators-remote-monitoring-automate.md#create-an-advanced-rule) section up to the point where you set a **Severity level**. Don't click **Apply** yet. |
| 62 | + |
| 63 | +1. In the **Action** section, toggle **Email enabled** to **On**. |
| 64 | + |
| 65 | +1. The first time you enable an email action in the solution accelerator, you must [sign in to Outlook](#outlook). |
| 66 | + |
| 67 | +1. Enter an email address into the recipient box and press the **Enter** key for each email address to add: |
| 68 | + |
| 69 | +  |
| 70 | + |
| 71 | +1. Enter a subject for the email. |
| 72 | + |
| 73 | +1. Enter any additional notes for the email recipients as plain text. You can use HTML formatting if you [edit the email template](#htmledit). |
| 74 | + |
| 75 | +1. Make sure that the **Rule Status** is set to **Enabled**. |
| 76 | + |
| 77 | +1. Click **Apply**. |
| 78 | + |
| 79 | +Your rule with an email action is now enabled. Each time the action is triggered, a new email is sent to the recipients. |
| 80 | + |
| 81 | +## Sign in to Outlook <a name="outlook"></a> |
| 82 | + |
| 83 | +The first time you enable an email action in your solution accelerator, you must sign into Outlook. This action sets up the email account that sends out the email notifications. |
| 84 | + |
| 85 | +> [!NOTE] |
| 86 | +> You should create a specific Outlook account just for solution accelerator notifications and use that account when you enable your first email action. |
| 87 | +
|
| 88 | +### Contributor role Outlook setup |
| 89 | + |
| 90 | +If someone in the **contributor** role in the subscription deployed the solution accelerator, the application doesn't have sufficient permissions to set up and verify email actions through the Web UI. |
| 91 | + |
| 92 | +Before you start, create an Outlook account to use to send email notifications from your solution accelerator. |
| 93 | + |
| 94 | +The following steps show you how to set up and verify the email actions manually: |
| 95 | + |
| 96 | +1. Navigate to the [Azure portal](https://portal.azure.com). |
| 97 | + |
| 98 | +1. Navigate to the Resource Group for your solution accelerator. |
| 99 | + |
| 100 | +1. Click the **office365-connector**: |
| 101 | + |
| 102 | +  |
| 103 | + |
| 104 | +1. Click the banner to begin the authorization process: |
| 105 | + |
| 106 | +  |
| 107 | + |
| 108 | +1. Click **Authorize**. You're prompted to sign in. The account you use to sign in should be the email address the application uses to send email notifications: |
| 109 | + |
| 110 | +  |
| 111 | + |
| 112 | +1. Click **Save** at the bottom. Your authorization will be successful if the banner is gone. |
| 113 | + |
| 114 | +1. To change the email address from which the notifications are sent from, click **Edit API connection**. |
| 115 | + |
| 116 | +  |
| 117 | + |
| 118 | +### Owner role Outlook setup |
| 119 | + |
| 120 | +If someone in the **owner** role in the subscription deployed the solution accelerator, the application can verify email actions have been correctly set up through the Web UI. |
| 121 | + |
| 122 | +Before you start, create an Outlook account to use to send email notifications from your solution accelerator. |
| 123 | + |
| 124 | +The following steps help you to sign in and set up email actions: |
| 125 | + |
| 126 | +1. Click to sign in to Outlook. You're taken to the Azure portal: |
| 127 | + |
| 128 | +  |
| 129 | + |
| 130 | +1. Click **Authorize**. You're prompted to sign in. The account you use to sign in should be the email address the application uses to send email notifications: |
| 131 | + |
| 132 | +1. Click **Save**. Return to your solution accelerator and refresh the page. |
| 133 | + |
| 134 | +1. If you've successfully configured the email notification, you see this message: |
| 135 | + |
| 136 | +  |
| 137 | + |
| 138 | +## Customize the email HTML <a name="htmledit"></a> |
| 139 | + |
| 140 | +Out-of-the-box, the Remote Monitoring solution accelerator provides a basic HTML template for action emails. The email template uses values from the email action settings. Here's an example email: |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | +The following steps show you how to edit the HTML email template. For example, you can include more information or add custom images: |
| 145 | + |
| 146 | +1. Clone either the Java or .NET Remote Monitoring GitHub repository: |
| 147 | + |
| 148 | +1. Navigate to the email template location: |
| 149 | + |
| 150 | + `Dotnet: device-telemetry\ActionsAgent\data\EmailTemplate.html` |
| 151 | + |
| 152 | + `Java device-telemetry/app/resources/data/EmailTemplate.html` |
| 153 | + |
| 154 | +1. You can add or remove any parameters in this template to customize the message. You can also add, remove, or replace calls as needed: |
| 155 | + |
| 156 | + For example, in the .NET code: |
| 157 | + `emailTemplate = emailTemplate.Replace("${subject}", emailAction.GetSubject());` |
| 158 | + |
| 159 | + For example, in the Java code: |
| 160 | + `this.emailTemplate.replace("${subject}", emailAction.GetSubject());` |
| 161 | + |
| 162 | +1. Parameters in the template take the form of `${...}`. To delete a parameter, delete the required line. To add a parameter, add a line with the value to insert. |
| 163 | + |
| 164 | +1. To add images or custom text, update the EmailTemplate.HTML file directly. |
| 165 | + |
| 166 | +## Throttling |
| 167 | + |
| 168 | +The Remote Monitoring solution accelerator uses Outlook to send email notifications. Outlook limits the number of emails sent to [30 emails per 1 minute](https://docs.microsoft.com/office365/servicedescriptions/exchange-online-service-description/exchange-online-limits#receiving-and-sending-limits). Email clients receiving the emails may also throttle the number of emails received per minute. Check with your specific email client on limitations. When you set up email notification for a rule, the rule should calculate average values over a period of at least one minute, and not use instant values: |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | +## Next steps |
| 173 | + |
| 174 | +This guide showed you how to add an email action to a new or existing rule within a Remote Monitoring solution. The guide also showed you and how to edit the HTML that defines the message format. |
| 175 | + |
| 176 | +The suggested next step is to learn [how to use alerts and fix device issues](iot-accelerators-remote-monitoring-maintain.md). |
0 commit comments