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
+49-21Lines changed: 49 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,8 @@ 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 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
20
+
HTTP request.
20
21
21
22
## Prerequisite
22
23
@@ -51,10 +52,13 @@ Deploy an app with the language framework of your choice to App Service. To foll
51
52
## Create the Logic App
52
53
53
54
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.
54
-
1. In the splash page for Logic Apps Designer, select **When a HTTP request is received** under **Start with a common trigger**.
55
+
1. In the splash page for Logic Apps Designer, select **When a
56
+
HTTP request is received** under **Start with a common trigger**.
@@ -68,14 +72,20 @@ Deploy an app with the language framework of your choice to App Service. To foll
68
72
}
69
73
```
70
74
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.
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.
72
78
1. At the top of the Logic Apps Designer, select **Save**.
73
79
74
-
You can now see the URL of your HTTP request trigger.
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).
85
+
This
86
+
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
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.
105
+
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.
95
107
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).
130
+
By default, the response action sends an HTTP 200. That's good enough for this tutorial. For more information, see the
1. At the top of the Logic Apps Designer, select **Save** again.
121
134
122
-
## Add HTTP request code to app
135
+
## Add
136
+
HTTP request code to app
123
137
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>*):
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>*):
125
140
126
141
```azurecli-interactive
127
142
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings LOGIC_APP_URL="<your-logic-app-url>"
128
143
```
129
144
130
145
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:
131
146
147
+
132
148
- The request body contains the same JSON format that you supplied to your logic app:
133
149
134
150
```json
@@ -137,9 +153,11 @@ In your code, make a standard HTTP post to the URL using any HTTP client languag
137
153
"due": "<date>",
138
154
"email": "<email-address>"
139
155
}
140
-
```.
156
+
```
157
+
141
158
- The request contains the heading `Content-Type: application/json`.
142
-
- To optimize performance, send the request asynchronously if possible.
159
+
- To optimize performance, sen
160
+
d the request asynchronously if possible.
143
161
144
162
Click on the preferred language/framework tab below to see an example.
145
163
@@ -192,7 +210,10 @@ var statusCode = result.StatusCode.ToString();
192
210
```
193
211
194
212
> [!NOTE]
195
-
> 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-http-requests).
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
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.
198
219
@@ -257,18 +278,23 @@ If you're testing this code on the sample app for [Tutorial: Build a PHP and MyS
257
278
258
279
# [Python](#tab/python)
259
280
260
-
In Python, you can send the HTTP post easily with [requests](https://pypi.org/project/requests/). For example:
0 commit comments