Skip to content

Commit 105bb28

Browse files
Merge pull request #110256 from kraigb/kraigb-sc1171
Simplify az webapp up commands to rely on local context
2 parents 2e4f9d5 + dc0844c commit 105bb28

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

articles/app-service/containers/quickstart-python.md

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Quickstart: Create a Linux Python app'
33
description: Get started with Linux apps on Azure App Service by deploying your first Python app to a Linux container in App Service.
44
ms.topic: quickstart
5-
ms.date: 10/22/2019
5+
ms.date: 04/03/2020
66
ms.custom: seo-python-october2019, cli-validate
77

88
experimental: true
@@ -20,7 +20,7 @@ If you prefer to deploy apps through an IDE, see [Deploy Python apps to App Serv
2020
- Azure subscription - [create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio)
2121
- <a href="https://www.python.org/downloads/" target="_blank">Python 3.7</a> (Python 3.6 is also supported)
2222
- <a href="https://git-scm.com/downloads" target="_blank">Git</a>
23-
- <a href="https://docs.microsoft.com/cli/azure/install-azure-cli" target="_blank">Azure CLI</a>
23+
- <a href="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.
2424

2525
## Download the sample
2626

@@ -94,39 +94,44 @@ az login
9494

9595
The [`az webapp up`](/cli/azure/webapp#az-webapp-up) command creates the web app on App Service and deploys your code.
9696

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 `-`*).
9898

9999

100100
```azurecli
101-
az webapp up --sku F1 -n <app-name> -l <location-name>
101+
az webapp up --sku F1 -n <app-name>
102102
```
103103

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

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>
108111
Creating Resource group 'appsvc_rg_Linux_centralus' ...
109112
Resource group creation complete
110113
Creating App service plan 'appsvc_asp_Linux_centralus' ...
111114
App service plan creation complete
112115
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
117122
{
118-
"app_url": "https:/<app-name>.azurewebsites.net",
119-
"location": "Central US",
123+
"URL": "http://<app-name>.net",
124+
"appserviceplan": "appsvc_asp_Linux_centralus",
125+
"location": "eastus",
120126
"name": "<app-name>",
121127
"os": "Linux",
122-
"resourcegroup": "appsvc_rg_Linux_centralus ",
123-
"serverfarm": "appsvc_asp_Linux_centralus",
124-
"sku": "BASIC",
125-
"src_path": "/home/username/quickstart/python-docs-hello-world ",
126-
"version_detected": "-",
127-
"version_to_create": "python|3.7"
128+
"resourcegroup": "appsvc_rg_Linux_centralus",
129+
"runtime_version": "python|3.7",
130+
"runtime_version_detected": "-",
131+
"sku": "FREE",
132+
"src_path": "D:\\Examples\\python-docs-hello-world"
128133
}
129-
```
134+
</pre>
130135

131136
[!INCLUDE [AZ Webapp Up Note](../../../includes/app-service-web-az-webapp-up-note.md)]
132137

@@ -142,21 +147,24 @@ The Python sample code is running a Linux container in App Service using a built
142147

143148
## Redeploy updates
144149

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

147152
```python
148-
print("Handling request to home page.")
149-
return "Hello Azure!"
153+
def hello():
154+
print("Handling request to home page.")
155+
return "Hello Azure!"
150156
```
151157

152158
Save your changes and exit the editor.
153159

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:
155161

156162
```azurecli
157-
az webapp up --sku F1 -n <app-name> -l <location-name>
163+
az webapp up
158164
```
159165

166+
This command uses values that are cached in the *.azure/config* file, including the app name, resource group, and App Service plan.
167+
160168
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:
161169

162170
![Run an updated sample Python app in Azure](./media/quickstart-python/run-updated-hello-world-sample-python-app-in-browser.png)
@@ -168,24 +176,18 @@ Once deployment has completed, switch back to the browser window open to `http:/
168176

169177
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.
170178

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:
172180

173181
```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
181183
```
182184

183185
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.
184186

185-
```output
186-
2019-10-23T12:40:03.815574424Z Handling request to home page.
187-
2019-10-23T12:40:03.815602424Z 172.16.0.1 - - [23/Oct/2019:12:40:03 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.63 Safari/537.36 Edg/78.0.276.19"
188-
```
187+
<pre>
188+
2020-04-03T22:54:04.236405938Z Handling request to home page.
189+
2020-04-03T22:54:04.236497641Z 172.16.0.1 - - [03/Apr/2020:22:54:04 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.83 Safari/537.36 Edg/81.0.416.41"
190+
</pre>
189191

190192
You can also inspect the log files from the browser at `https://<app-name>.scm.azurewebsites.net/api/logs/docker`.
191193

@@ -209,7 +211,7 @@ The App Service menu provides different pages for configuring your app.
209211

210212
## Clean up resources
211213

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/)).
213215

214216
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.
215217

0 commit comments

Comments
 (0)