Skip to content

Commit e02bc56

Browse files
authored
Merge pull request #193646 from charris-msft/main
Update quickstart-python to use az webapp up for the CLI
2 parents 4ffb336 + e9803a7 commit e02bc56

File tree

3 files changed

+78
-100
lines changed

3 files changed

+78
-100
lines changed
Lines changed: 4 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,9 @@
11
---
2-
author: DavidCBerry13
3-
ms.author: daberry
2+
author: charris-msft
3+
ms.author: charris
44
ms.topic: include
5-
ms.date: 01/29/2022
5+
ms.date: 04/01/2022
66
---
7-
Azure CLI commands can be run in the [Azure Cloud Shell](https://shell.azure.com) or on a workstation with the [Azure CLI installed](/cli/azure/install-azure-cli).
8-
9-
First, create a resource group to act as a container for all of the Azure resources related to this application.
10-
11-
#### [bash](#tab/terminal-bash)
12-
13-
```azurecli
14-
# Use 'az account list-locations --output table' to list locations
15-
LOCATION='eastus'
16-
RESOURCE_GROUP_NAME='msdocs-python-webapp-quickstart'
17-
18-
az group create \
19-
--location $LOCATION \
20-
--name $RESOURCE_GROUP_NAME
21-
```
22-
23-
#### [PowerShell terminal](#tab/terminal-powershell)
24-
25-
```azurecli
26-
# Use 'az account list-locations --output table' to list locations
27-
$LOCATION='eastus'
28-
$RESOURCE_GROUP_NAME='msdocs-python-webapp-quickstart'
29-
30-
# Create a resource group
31-
az group create `
32-
--location $LOCATION `
33-
--name $RESOURCE_GROUP_NAME
34-
```
35-
36-
---
37-
38-
Next, create an App Service plan using the [az appservice plan create](/cli/azure/appservice/plan#az-appservice-plan-create) command.
39-
40-
* The `--sku` parameter defines the size (CPU, memory) and cost of the app service plan. This example uses the B1 (Basic) service plan, which will incur a small cost in your Azure subscription. For a full list of App Service plans, view the [App Service pricing](https://azure.microsoft.com/pricing/details/app-service/linux/) page.
41-
* The `--is-linux` flag selects the Linux as the host operating system.
42-
43-
#### [bash](#tab/terminal-bash)
44-
45-
```azurecli
46-
APP_SERVICE_PLAN_NAME='msdocs-python-webapp-quickstart'
47-
48-
az appservice plan create \
49-
--name $APP_SERVICE_PLAN_NAME \
50-
--resource-group $RESOURCE_GROUP_NAME \
51-
--sku B1 \
52-
--is-linux
53-
```
54-
55-
#### [PowerShell terminal](#tab/terminal-powershell)
56-
57-
```azurecli
58-
$APP_SERVICE_PLAN_NAME='msdocs-python-webapp-quickstart'
59-
60-
az appservice plan create `
61-
--name $APP_SERVICE_PLAN_NAME `
62-
--resource-group $RESOURCE_GROUP_NAME `
63-
--sku B1 `
64-
--is-linux
65-
```
66-
67-
---
68-
69-
Finally, create the App Service web app using the [az webapp create](/cli/azure/webapp#az-webapp-create) command.
70-
71-
* The *app service name* is used as both the name of the resource in Azure and to form the fully qualified domain name for your app in the form of `https://<app service name>.azurewebsites.com`.
72-
* The runtime specifies what version of Python your app is running. This example uses Python 3.9. To list all available runtimes, use the command `az webapp list-runtimes --os linux --output table`.
73-
74-
#### [bash](#tab/terminal-bash)
75-
76-
```azurecli
77-
# Change 123 to any three characters to form a unique name across Azure
78-
APP_SERVICE_NAME='msdocs-python-webapp-quickstart-123'
79-
80-
az webapp create \
81-
--name $APP_SERVICE_NAME \
82-
--runtime 'PYTHON|3.9' \
83-
--plan $APP_SERVICE_PLAN_NAME \
84-
--resource-group $RESOURCE_GROUP_NAME \
85-
--query 'defaultHostName' \
86-
--output table
87-
```
88-
89-
#### [PowerShell terminal](#tab/terminal-powershell)
90-
91-
```azurecli
92-
# Change 123 to any three characters to form a unique name across Azure
93-
$APP_SERVICE_NAME='msdocs-python-webapp-quickstart-123'
94-
95-
az webapp create `
96-
--name $APP_SERVICE_NAME `
97-
--runtime 'PYTHON:3.9' `
98-
--plan $APP_SERVICE_PLAN_NAME `
99-
--resource-group $RESOURCE_GROUP_NAME `
100-
--query 'defaultHostName' `
101-
--output table
102-
```
7+
Azure CLI has a command `az webapp up` that will create the necessary resources and deploy your application in a single step. You don't need to create the resources separately so you can move on to [**Step 3 - Deploy your application code to Azure**](#3---deploy-your-application-code-to-azure) and select the _Deploy using Azure CLI_ tab.
1038

1049
---
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
author: charris-msft
3+
ms.author: charris
4+
ms.topic: include
5+
ms.date: 04/01/2022
6+
---
7+
Azure CLI commands can be run in the [Azure Cloud Shell](https://shell.azure.com) or on a workstation with the [Azure CLI installed](/cli/azure/install-azure-cli).
8+
9+
Azure CLI has a command `az webapp up` that will create the necessary resources and deploy your application in a single step.
10+
11+
#### [bash](#tab/terminal-bash)
12+
13+
Create the webapp and other resources, then deploy your code to Azure using [az webapp up](/cli/azure/webapp#az-webapp-up).
14+
15+
```azurecli
16+
az webapp up \
17+
--runtime 'PYTHON:3.9' \
18+
--sku B1 \
19+
--logs
20+
```
21+
22+
#### [PowerShell terminal](#tab/terminal-powershell)
23+
24+
Create the webapp and other resources, then deploy your code to Azure using [az webapp up](/cli/azure/webapp#az-webapp-up).
25+
26+
```azurecli
27+
az webapp up `
28+
--runtime 'PYTHON:3.9' `
29+
--sku B1 `
30+
--logs
31+
```
32+
33+
---
34+
35+
* The `--runtime` parameter specifies what version of Python your app is running. This example uses Python 3.9. To list all available runtimes, use the command `az webapp list-runtimes --os linux --output table`.
36+
* The `--sku` parameter defines the size (CPU, memory) and cost of the app service plan. This example uses the B1 (Basic) service plan, which will incur a small cost in your Azure subscription. For a full list of App Service plans, view the [App Service pricing](https://azure.microsoft.com/pricing/details/app-service/linux/) page.
37+
* The `--logs` flag configures default logging required to enable viewing the log stream immediately after launching the webapp.
38+
* You can optionally specify a name with the argument `--name <app-name>`. If you don't provide one, then a name will be automatically generated.
39+
* You can optionally include the argument `--location <location-name>` where `<location_name>` is an available Azure region. You can retrieve a list of allowable regions for your Azure account by running the [`az account list-locations`](/cli/azure/appservice#az-appservice-list-locations) command.
40+
41+
The command may take a few minutes to complete. While the command is running, it provides messages about creating the resource group, the App Service plan, and the app resource, configuring logging, and doing ZIP deployment. It then gives the message, "You can launch the app at http://&lt;app-name&gt;.azurewebsites.net", which is the app's URL on Azure.
42+
43+
<pre>
44+
The webapp '&lt;app-name>' doesn't exist
45+
Creating Resource group '&lt;group-name>' ...
46+
Resource group creation complete
47+
Creating AppServicePlan '&lt;app-service-plan-name>' ...
48+
Creating webapp '&lt;app-name>' ...
49+
Configuring default logging for the app, if not already enabled
50+
Creating zip with contents of dir /home/cephas/myExpressApp ...
51+
Getting scm site credentials for zip deployment
52+
Starting zip deployment. This operation can take a while to complete ...
53+
Deployment endpoint responded with status code 202
54+
You can launch the app at http://&lt;app-name>.azurewebsites.net
55+
{
56+
"URL": "http://&lt;app-name>.azurewebsites.net",
57+
"appserviceplan": "&lt;app-service-plan-name>",
58+
"location": "centralus",
59+
"name": "&lt;app-name>",
60+
"os": "&lt;os-type>",
61+
"resourcegroup": "&lt;group-name>",
62+
"runtime_version": "python|3.9",
63+
"runtime_version_detected": "0.0",
64+
"sku": "FREE",
65+
"src_path": "&lt;your-folder-location>"
66+
}
67+
</pre>
68+
69+
[!INCLUDE [az webapp up command note](../../../../includes/app-service-web-az-webapp-up-note.md)]

articles/app-service/quickstart-python.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To run the application locally:
3939

4040
### [Flask](#tab/flask)
4141

42-
1. Go to the application folder:
42+
1. Go to the application folder:
4343

4444
```Console
4545
cd msdocs-python-flask-webapp-quickstart
@@ -157,6 +157,10 @@ To deploy a web app from VS Code, you must have the [Azure Tools extension pack]
157157
| [!INCLUDE [VS Code deploy step 4](<./includes/quickstart-python/deploy-visual-studio-code-4.md>)] | :::image type="content" source="./media/quickstart-python/deploy-visual-studio-code-4-240px.png" alt-text="A screenshot of a dialog box in VS Code asking if you want to update your workspace to run build commands." lightbox="./media/quickstart-python/deploy-visual-studio-code-4.png"::: |
158158
| [!INCLUDE [VS Code deploy step 5](<./includes/quickstart-python/deploy-visual-studio-code-5.md>)] | :::image type="content" source="./media/quickstart-python/deploy-visual-studio-code-5-240px.png" alt-text="A screenshot showing the confirmation dialog when the app code has been deployed to Azure." lightbox="./media/quickstart-python/deploy-visual-studio-code-5.png"::: |
159159

160+
### [Deploy using Azure CLI](#tab/azure-cli-deploy)
161+
162+
[!INCLUDE [Deploy Azure CLI](<./includes/quickstart-python/deploy-cli.md>)]
163+
160164
### [Deploy using Local Git](#tab/local-git-deploy)
161165

162166
[!INCLUDE [Deploy Local Git](<./includes/quickstart-python/deploy-local-git.md>)]

0 commit comments

Comments
 (0)