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/app-service/tutorial-send-email.md
+18-42Lines changed: 18 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,7 @@ In this tutorial, you learn how to integrate your App Service app with the busin
16
16
- Connect to third-party systems like SAP, SalesForce, etc.
17
17
- Exchange standard B2B messages
18
18
19
-
In this tutorial, you send emails from your App Service app using Gmail using [Azure Logic Apps](../logic-apps/logic-apps-overview.md). There are other ways to send emails from a web app, such as SMTP configuration provided by your language framework. However, Logic Apps brings a lot more power to your App Service app without adding complexity to your code. Logic Apps provides a simple configuration interface for the most popular business integrations, and your app can call them anytime with an
20
-
HTTP request.
19
+
In this tutorial, you send emails from your App Service app using Gmail using [Azure Logic Apps](../logic-apps/logic-apps-overview.md). There are other ways to send emails from a web app, such as SMTP configuration provided by your language framework. However, Logic Apps brings a lot more power to your App Service app without adding complexity to your code. Logic Apps provides a simple configuration interface for the most popular business integrations, and your app can call them anytime with an HTTP request.
21
20
22
21
## Prerequisite
23
22
@@ -52,13 +51,10 @@ Deploy an app with the language framework of your choice to App Service. To foll
52
51
## Create the Logic App
53
52
54
53
1. In the [Azure portal](https://portal.azure.com), create an empty logic app by following the instructions in [Create your logic app](../logic-apps/quickstart-create-first-logic-app-workflow.md#create-your-logic-app). When you see the **Logic Apps Designer**, return to this tutorial.
55
-
1. In the splash page for Logic Apps Designer, select **When a
56
-
HTTP request is received** under **Start with a common trigger**.
54
+
1. In the splash page for Logic Apps Designer, select **When an HTTP request is received** under **Start with a common trigger**.
57
55
58
-

60
-
1. In the dialog for **When a
61
-
HTTP request is received**, select **Use sample payload to generate schema**.
@@ -72,20 +68,14 @@ Deploy an app with the language framework of your choice to App Service. To foll
72
68
}
73
69
```
74
70
75
-
The schema is now generated fo
76
-
r the request data you want. In practice, you can just capture the a
77
-
ctual request data your application code generates and let Azure generate the JSON schema for you.
71
+
The schema is now generated for the request data you want. In practice, you can just capture the actual request data your application code generates and let Azure generate the JSON schema for you.
78
72
1. At the top of the Logic Apps Designer, select **Save**.
79
73
80
-
You can now see the URL of your
81
-
HTTP request trigger.
74
+
You can now see the URL of your HTTP request trigger.
HTTP request definition is a trigger to anything you want to do in this logic app, be it Gmail or anything else. Later you will invoke this URL in your App Service app. For more information o
This HTTP request definition is a trigger to anything you want to do in this logic app, be it Gmail or anything else. Later you will invoke this URL in your App Service app. For more information on the request trigger, see the [HTTP request/response reference](../connectors/connectors-native-reqres.md).
89
79
90
80
1. At the bottom of the designer, click **New step**, type **Gmail** in the actions search box and find and select **Send email (V2)**.
91
81
@@ -97,13 +87,11 @@ Deploy an app with the language framework of your choice to App Service. To foll
97
87
98
88
1. Once signed in, click in the **To** textbox, and the dynamic content dialog is automatically opened.
99
89
100
-
1. Next to the **When a
101
-
HTTP request is received** action, select **See more**.
90
+
1. Next to the **When an HTTP request is received** action, select **See more**.
You should now see the three properties from your sample JSON data you used earlier. In this step, you use these properties from the
106
-
HTTP request to construct an email.
94
+
You should now see the three properties from your sample JSON data you used earlier. In this step, you use these properties from the HTTP request to construct an email.
107
95
1. Since you're selecting the value for the **To** field, choose **email**. If you want, toggle off the dynamic content dialog by clicking **Add dynamic content**.
By default, the response action sends an HTTP 200. That's good enough for this tutorial. For more information, see the [HTTP request/response reference](../connectors/connectors-native-reqres.md).
132
119
133
120
1. At the top of the Logic Apps Designer, select **Save** again.
134
121
135
-
## Add
136
-
HTTP request code to app
122
+
## Add HTTP request code to app
137
123
138
-
Make sure you have copied the URL of the
139
-
HTTP request trigger from earlier. First, create an app setting in your App Service app. In the [Cloud Shell](https://shell.azure.com), you can do it with the following command (replace *\<app-name>*, *\<resource-group-name>*, and *\<logic-app-url>*):
124
+
Make sure you have copied the URL of the HTTP request trigger from earlier. First, create an app setting in your App Service app. In the [Cloud Shell](https://shell.azure.com), you can do it with the following command (replace *\<app-name>*, *\<resource-group-name>*, and *\<logic-app-url>*):
140
125
141
126
```azurecli-interactive
142
127
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings LOGIC_APP_URL="<your-logic-app-url>"
143
128
```
144
129
145
130
In your code, make a standard HTTP post to the URL using any HTTP client language that's available to your language framework, with the following configuration:
146
131
147
-
148
132
- The request body contains the same JSON format that you supplied to your logic app:
149
133
150
134
```json
@@ -156,8 +140,7 @@ In your code, make a standard HTTP post to the URL using any HTTP client languag
156
140
```
157
141
158
142
- The request contains the heading `Content-Type: application/json`.
159
-
- To optimize performance, sen
160
-
d the request asynchronously if possible.
143
+
- To optimize performance, send the request asynchronously if possible.
161
144
162
145
Click on the preferred language/framework tab below to see an example.
163
146
@@ -210,9 +193,7 @@ var statusCode = result.StatusCode.ToString();
210
193
```
211
194
212
195
> [!NOTE]
213
-
> This code is written for simplicity of demonstration. In practice, don't instantiate an `HttpClient` object for
214
-
each request. Follow the guidance at [Use IHttpClientFactory to implement resilient
> This code is written for simplicity of demonstration. In practice, don't instantiate an `HttpClient` object for each request. Follow the guidance at [Use IHttpClientFactory to implement resilient HTTP requests](https://docs.microsoft.com/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient
216
197
-http-requests).
217
198
218
199
If you're testing this code on the sample app for [Tutorial: Build an ASP.NET Core and SQL Database app in Azure App Service](app-service-web-tutorial-dotnetcore-sqldb.md), you could use it to send an email confirmation in the [Create action](https://github.com/Azure-Samples/dotnetcore-sqldb-tutorial/blob/master/Controllers/TodosController.cs#L56-L65), after the `Todo` item is added.
@@ -278,23 +259,18 @@ If you're testing this code on the sample app for [Tutorial: Build a PHP and MyS
278
259
279
260
# [Python](#tab/python)
280
261
281
-
In Python, you can send the HTTP post easily
282
-
with [requests](https://pypi.org/pr
283
-
oject/requests/). For example:
262
+
In Python, you can send the HTTP post easily with [requests](https://pypi.org/project/requests/). For example:
0 commit comments