Skip to content

Commit 557f419

Browse files
committed
staged review
1 parent 5ab4b29 commit 557f419

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

articles/app-service/tutorial-send-email.md

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ In this tutorial, you learn how to integrate your App Service app with the busin
1616
- Connect to third-party systems like SAP, SalesForce, etc.
1717
- Exchange standard B2B messages
1818

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.
2021

2122
## Prerequisite
2223

@@ -51,10 +52,13 @@ Deploy an app with the language framework of your choice to App Service. To foll
5152
## Create the Logic App
5253

5354
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**.
5557

56-
![](./media/tutorial-send-email/receive-http-request.png)
57-
1. In the dialog for **When a HTTP request is received**, select **Use sample payload to generate schema**.
58+
![](./media/tutorial-send-email/receive
59+
-http-request.png)
60+
1. In the dialog for **When a
61+
HTTP request is received**, select **Use sample payload to generate schema**.
5862

5963
![](./media/tutorial-send-email/generate-schema-with-payload.png)
6064

@@ -68,14 +72,20 @@ Deploy an app with the language framework of your choice to App Service. To foll
6872
}
6973
```
7074

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.
7278
1. At the top of the Logic Apps Designer, select **Save**.
7379

74-
You can now see the URL of your HTTP request trigger.
80+
You can now see the URL of your
81+
HTTP request trigger.
7582

7683
![](./media/tutorial-send-email/generate-schema-with-payload.png)
7784

78-
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
87+
n the request trigger, see the
88+
[HTTP request/response reference](../connectors/connectors-native-reqres.md).
7989

8090
1. At the bottom of the designer, click **New step**, type **Gmail** in the actions search box and find and select **Send email (V2)**.
8191

@@ -87,11 +97,13 @@ Deploy an app with the language framework of your choice to App Service. To foll
8797

8898
1. Once signed in, click in the **To** textbox, and the dynamic content dialog is automatically opened.
8999

90-
1. Next to the **When a HTTP request is received** action, select **See more**.
100+
1. Next to the **When a
101+
HTTP request is received** action, select **See more**.
91102

92-
![](./media/tutorial-send-email/gmail-sign-in.png)
103+
![](./media/tutorial-send-email/expand-dynamic-content.png)
93104

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.
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.
95107
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**.
96108

97109
![](./media/tutorial-send-email/hide-dynamic-content.png)
@@ -115,20 +127,24 @@ Deploy an app with the language framework of your choice to App Service. To foll
115127

116128
![](./media/tutorial-send-email/choose-response-action.png)
117129

118-
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
131+
[HTTP request/response reference](../connectors/connectors-native-reqres.md).
119132

120133
1. At the top of the Logic Apps Designer, select **Save** again.
121134

122-
## Add HTTP request code to app
135+
## Add
136+
HTTP request code to app
123137

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>*):
125140

126141
```azurecli-interactive
127142
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings LOGIC_APP_URL="<your-logic-app-url>"
128143
```
129144

130145
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:
131146

147+
132148
- The request body contains the same JSON format that you supplied to your logic app:
133149

134150
```json
@@ -137,9 +153,11 @@ In your code, make a standard HTTP post to the URL using any HTTP client languag
137153
"due": "<date>",
138154
"email": "<email-address>"
139155
}
140-
```.
156+
```
157+
141158
- 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.
143161

144162
Click on the preferred language/framework tab below to see an example.
145163

@@ -192,7 +210,10 @@ var statusCode = result.StatusCode.ToString();
192210
```
193211

194212
> [!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
215+
HTTP requests](https://docs.microsoft.com/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient
216+
-http-requests).
196217

197218
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.
198219

@@ -257,18 +278,23 @@ If you're testing this code on the sample app for [Tutorial: Build a PHP and MyS
257278

258279
# [Python](#tab/python)
259280

260-
In Python, you can send the HTTP post easily with [requests](https://pypi.org/project/requests/). For example:
281+
In Python, you can send the HTTP post easily
282+
with [requests](https://pypi.org/pr
283+
oject/requests/). For example:
261284

262285
```python
263-
# Requires pip install requests && pip freeze > requirements.txt
264-
import requests
286+
# Requires pip in
287+
stall requests && pip freeze > requirements.txt
288+
i
289+
mport requests
265290
...
266291
payload = {
267292
"email": "[email protected]",
268293
"due": "4/1/2020",
269294
"task": "My new task!"
270295
}
271-
response = requests.post("https://prod-112.westeurope.logic.azure.com:443/workfl$
296+
respo
297+
nse = requests.post("https://prod-112.westeurope.logic.azure.com:443/workfl$
272298
print(response.status_code)
273299
```
274300
<!-- ```python
@@ -307,4 +333,6 @@ If you're testing this code on the sample app for [Build a Ruby and Postgres app
307333

308334
# More resources
309335

310-
[Tutorial: Host a RESTful API with CORS in Azure App Service](app-service-web-tutorial-rest-api.md)
336+
[Tutorial: Host a RESTful API with CORS in Azure App Service](app-service-web-tutorial-rest-api.md)
337+
[HTTP request/response reference for Logic Apps](../connectors/connectors-native-reqres.md)
338+
[Quickstart: Create your first workflow by using Azure Logic Apps - Azure portal](../logic-apps/quickstart-create-first-logic-app-workflow)

0 commit comments

Comments
 (0)