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/containers/quickstart-python.md
+40-38Lines changed: 40 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: 'Quickstart: Create a Linux Python app'
3
3
description: Get started with Linux apps on Azure App Service by deploying your first Python app to a Linux container in App Service.
4
4
ms.topic: quickstart
5
-
ms.date: 10/22/2019
5
+
ms.date: 04/03/2020
6
6
ms.custom: seo-python-october2019, cli-validate
7
7
8
8
experimental: true
@@ -20,7 +20,7 @@ If you prefer to deploy apps through an IDE, see [Deploy Python apps to App Serv
20
20
- Azure subscription - [create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio)
21
21
- <ahref="https://www.python.org/downloads/"target="_blank">Python 3.7</a> (Python 3.6 is also supported)
- <ahref="https://docs.microsoft.com/cli/azure/install-azure-cli"target="_blank">Azure CLI</a> 2.0.80 or higher. Run `az --version` to check your version.
24
24
25
25
## Download the sample
26
26
@@ -94,39 +94,44 @@ az login
94
94
95
95
The [`az webapp up`](/cli/azure/webapp#az-webapp-up) command creates the web app on App Service and deploys your code.
96
96
97
-
In the *python-docs-hello-world* folder that contains the sample code, run the following `az webapp up` command. Replace `<app-name>` with a globally unique app name (*valid characters are `a-z`, `0-9`, and `-`*). Also replace `<location-name>` with an Azure region such as **centralus**, **eastasia**, **westeurope**, **koreasouth**, **brazilsouth**, **centralindia**, and so on. (You can retrieve a list of allowable regions for your Azure account by running the [`az account list-locations`](/cli/azure/appservice?view=azure-cli-latest.md#az-appservice-list-locations) command.)
97
+
In the *python-docs-hello-world* folder that contains the sample code, run the following `az webapp up` command. Replace `<app-name>` with a globally unique app name (*valid characters are `a-z`, `0-9`, and `-`*).
98
98
99
99
100
100
```azurecli
101
-
az webapp up --sku F1 -n <app-name> -l <location-name>
101
+
az webapp up --sku F1 -n <app-name>
102
102
```
103
103
104
-
This command may take a few minutes to completely run. While running, it displays information similar to the following example:
104
+
The `--sku F1` argument creates the web app on the Free pricing tier. You can omit this argument to use a premium tier instead, which incurs an hourly cost.
105
105
106
-
```output
107
-
The behavior of this command has been altered by the following extension: webapp
106
+
You can optionally include the argument `-l <location-name>` where `<location_name>` is an Azure region such as **centralus**, **eastasia**, **westeurope**, **koreasouth**, **brazilsouth**, **centralindia**, and so on. You can retrieve a list of allowable regions for your Azure account by running the [`az account list-locations`](/cli/azure/appservice?view=azure-cli-latest.md#az-appservice-list-locations) command.
107
+
108
+
The `az webapp up` command may take a few minutes to completely run. While running, it displays information similar to the following example, where `<app_name>` will be the name you provided earlier:
109
+
110
+
<pre>
108
111
Creating Resource group 'appsvc_rg_Linux_centralus' ...
109
112
Resource group creation complete
110
113
Creating App service plan 'appsvc_asp_Linux_centralus' ...
111
114
App service plan creation complete
112
115
Creating app '<app-name>' ....
113
-
Webapp creation complete
114
-
Creating zip with contents of dir /home/username/quickstart/python-docs-hello-world ...
115
-
Preparing to deploy contents to app.
116
-
All done.
116
+
Configuring default logging for the app, if not already enabled
117
+
Creating zip with contents of dir D:\Examples\python-docs-hello-world ...
118
+
Getting scm site credentials for zip deployment
119
+
Starting zip deployment. This operation can take a while to complete ...
120
+
Deployment endpoint responded with status code 202
121
+
You can launch the app at http://<app-name>.azurewebsites.net
[!INCLUDE [AZ Webapp Up Note](../../../includes/app-service-web-az-webapp-up-note.md)]
132
137
@@ -142,21 +147,24 @@ The Python sample code is running a Linux container in App Service using a built
142
147
143
148
## Redeploy updates
144
149
145
-
In your favorite code editor, open *application.py* and change the `return` statement on the last line to match the following code. The `print` statement is included here to generate logging output that you work with in the next section.
150
+
In your favorite code editor, open *application.py* and update the `hello` function as follows. This change adds a `print` statement to generate logging output that you work with in the next section.
146
151
147
152
```python
148
-
print("Handling request to home page.")
149
-
return"Hello Azure!"
153
+
defhello():
154
+
print("Handling request to home page.")
155
+
return"Hello Azure!"
150
156
```
151
157
152
158
Save your changes and exit the editor.
153
159
154
-
Redeploy the app using the following `az webapp up` command, using the same command you used to deploy the app the first time, replacing `<app-name>` and `<location-name>` with the same names you used before.
160
+
Redeploy the app using the `az webapp up` command again:
155
161
156
162
```azurecli
157
-
az webapp up --sku F1 -n <app-name> -l <location-name>
163
+
az webapp up
158
164
```
159
165
166
+
This command uses values that are cached in the *.azure/config* file, including the app name, resource group, and App Service plan.
167
+
160
168
Once deployment has completed, switch back to the browser window open to `http://<app-name>.azurewebsites.net` and refresh the page, which should display the modified message:
161
169
162
170

@@ -168,24 +176,18 @@ Once deployment has completed, switch back to the browser window open to `http:/
168
176
169
177
You can access the console logs generated from inside the app and the container in which it runs. Logs include any output generated using `print` statements.
170
178
171
-
First, turn on container logging by running the following command in a terminal, replacing `<app-name>` with the name of your app and `<resource-group-name>` with the name of the resource group shown in the output of the `az webapp up` command you used (such as "appsvc_rg_Linux_centralus"):
179
+
To stream logs, run the following command:
172
180
173
181
```azurecli
174
-
az webapp log config --name <app-name> --resource-group <resource-group-name> --docker-container-logging filesystem
175
-
```
176
-
177
-
Once container logging is turned on, run the following command to show the log stream:
178
-
179
-
```azurecli
180
-
az webapp log tail --name <app-name> --resource-group <resource-group-name>
182
+
az webapp log tail
181
183
```
182
184
183
185
Refresh the app in the browser to generate console logs, which should include lines similar to the following text. If you don't see output immediately, try again in 30 seconds.
184
186
185
-
```output
186
-
2019-10-23T12:40:03.815574424Z Handling request to home page.
You can also inspect the log files from the browser at `https://<app-name>.scm.azurewebsites.net/api/logs/docker`.
191
193
@@ -209,7 +211,7 @@ The App Service menu provides different pages for configuring your app.
209
211
210
212
## Clean up resources
211
213
212
-
In the preceding steps, you created Azure resources in a resource group. The resource group has a name like "appsvc_rg_Linux_CentralUS" depending on your location. If you use an App Service SKU other than the free F1 tier, these resources will incur ongoing costs.
214
+
In the preceding steps, you created Azure resources in a resource group. The resource group has a name like "appsvc_rg_Linux_CentralUS" depending on your location. If you use an App Service SKU other than the free F1 tier, these resources incur ongoing costs (see [App Service pricing](https://azure.microsoft.com/pricing/details/app-service/linux/)).
213
215
214
216
If you don't expect to need these resources in the future, delete the resource group by running the following command, replacing `<resource-group-name>` with the resource group shown in the output of the `az webapp up` command, such as "appsvc_rg_Linux_centralus". The command may take a minute to complete.
0 commit comments