Skip to content

Commit 4508a0e

Browse files
committed
Added output section to AZD step 1
1 parent 5ba5f22 commit 4508a0e

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

articles/app-service/tutorial-python-postgresql-app-fastapi.md

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ zone_pivot_groups: app-service-portal-azd
1212

1313
# Deploy a Python FastAPI web app with PostgreSQL in Azure
1414

15-
In this tutorial, you'll deploy a data-driven Python web app (**[FastAPI](https://fastapi.tiangolo.com/)** ) to **[Azure App Service](./overview.md#app-service-on-linux)** with the **[Azure Database for PostgreSQL](../postgresql/index.yml)** relational database service. Azure App Service supports [Python](https://www.python.org/downloads/) in a Linux server environment.
15+
In this tutorial, you deploy a data-driven Python web app (**[FastAPI](https://fastapi.tiangolo.com/)** ) to **[Azure App Service](./overview.md#app-service-on-linux)** with the **[Azure Database for PostgreSQL](../postgresql/index.yml)** relational database service. Azure App Service supports [Python](https://www.python.org/downloads/) in a Linux server environment.
1616

1717
:::image type="content" border="False" source="./media/tutorial-python-postgresql-app-fastapi/python-postgresql-app-architecture-240px.png" lightbox="./media/tutorial-python-postgresql-app-fastapi/python-postgresql-app-architecture.png" alt-text="An architecture diagram showing an App Service with a PostgreSQL database in Azure.":::
1818

@@ -92,7 +92,7 @@ python3 -m uvicorn fastapi_app:app --reload --port=8000
9292

9393
## 1. Create App Service and PostgreSQL
9494

95-
In this step, you create the Azure resources. The steps used in this tutorial create a set of secure-by-default resources that include App Service and Azure Database for PostgreSQL. For the creation process, you'll specify:
95+
In this step, you create the Azure resources. The steps used in this tutorial create a set of secure-by-default resources that include App Service and Azure Database for PostgreSQL. For the creation process, you specify:
9696

9797
* The **Name** for the web app. It's the name used as part of the DNS name for your webapp in the form of `https://<app-name>.azurewebsites.net`.
9898
* The **Region** to run the app physically in the world.
@@ -170,7 +170,7 @@ The creation wizard generated the connectivity variables for you already as [app
170170
:::row-end:::
171171
:::row:::
172172
:::column span="2":::
173-
**Step 2:** In the **App settings** tab of the **Environment variables** page, verify that `AZURE_POSTGRESQL_CONNECTIONSTRING` is present. That will be injected into the runtime environment as an environment variable.
173+
**Step 2:** In the **App settings** tab of the **Environment variables** page, verify that `AZURE_POSTGRESQL_CONNECTIONSTRING` is present. The connection string will be injected into the runtime environment as an environment variable.
174174
:::column-end:::
175175
:::column:::
176176
:::image type="content" source="./media/tutorial-python-postgresql-app-fastapi/azure-portal-get-connection-string-fastapi-2.png" alt-text="A screenshot showing how to see the autogenerated connection string (FastAPI)." lightbox="./media/tutorial-python-postgresql-app-fastapi/azure-portal-get-connection-string-fastapi-2.png":::
@@ -179,7 +179,7 @@ The creation wizard generated the connectivity variables for you already as [app
179179

180180
## 3. Deploy sample code
181181

182-
In this step, you'll configure GitHub deployment using GitHub Actions. It's just one of many ways to deploy to App Service, but also a great way to have continuous integration in your deployment process. By default, every `git push` to your GitHub repository will kick off the build and deploy action.
182+
In this step, you configure GitHub deployment using GitHub Actions. It's just one of many ways to deploy to App Service, but also a great way to have continuous integration in your deployment process. By default, every `git push` to your GitHub repository will kick off the build and deploy action.
183183

184184
:::row:::
185185
:::column span="2":::
@@ -303,7 +303,7 @@ With the PostgreSQL database protected by the virtual network, the easiest way t
303303

304304
## 6. Stream diagnostic logs
305305

306-
The sample app uses the Python Standard Library logging module to help you diagnose issues with your application. The sample app includes calls to the logger as shown below.
306+
The sample app uses the Python Standard Library logging module to help you diagnose issues with your application. The sample app includes calls to the logger as shown in the following code.
307307

308308
:::code language="python" source="~/msdocs-fastapi-postgresql-sample-app/src/fastapi_app/app.py" range="39-46" highlight="3":::
309309

@@ -392,13 +392,13 @@ In this step, you create the Azure resources and deploy a sample app to App Serv
392392
|What would you like to do with these files? | **Keep my existing files unchanged** |
393393
|Enter a new environment name | Type a unique name. The azd template uses this name as part of the DNS name of your web app in Azure (`<app-name>.azurewebsites.net`). Alphanumeric characters and hyphens are allowed. |
394394

395-
1. Run the `azd up` command to provision the necessary Azure resources and deploy the app code. If you are not already signed-in to Azure, the browser will launch and ask you to sign-in. The `azd up` command will also prompt you to select the desired subscription and location to deploy to.
395+
1. Run the `azd up` command to provision the necessary Azure resources and deploy the app code. If you aren't already signed-in to Azure, the browser will launch and ask you to sign-in. The `azd up` command will also prompt you to select the desired subscription and location to deploy to.
396396
397397
```bash
398398
azd up
399399
```
400400
401-
The `azd up` command can take a several minutes to complete. It also compiles and deploys your application code. While it's running, the command provides messages about the provisioning and deployment process, including a link to the deployment in Azure. When it finishes, the command also displays a link to the deploy application.
401+
The `azd up` command can take several minutes (up to 45) to complete. It also compiles and deploys your application code. While it's running, the command provides messages about the provisioning and deployment process, including a link to the deployment in Azure. When it finishes, the command also displays a link to the deploy application.
402402

403403
This azd template contains files (*azure.yaml* and the *infra* directory) that generate a secure-by-default architecture with the following Azure resources:
404404

@@ -410,7 +410,36 @@ In this step, you create the Azure resources and deploy a sample app to App Serv
410410
- **Private DNS zone** &rarr; Enables DNS resolution of the PostgreSQL server in the virtual network.
411411
- **Log Analytics workspace** &rarr; Acts as the target container for your app to ship its logs, where you can also query the logs.
412412

413-
Note down the values for the **Subscription ID** (Guid), the **App Service**, and the **Resource Group** in the output. You'll use them in the following sections.
413+
1. When the `azd up` command completes, note down the values for the **Subscription ID** (Guid), the **App Service**, and the **Resource Group** in the output. You use them in the following sections. Your output will look similar to the following (partial) output:
414+
415+
```output
416+
Subscription: Your subscription name (1111111-1111-1111-1111-111111111111)
417+
Location: East US
418+
419+
You can view detailed progress in the Azure Portal:
420+
https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/overview/id/%2Fsubscriptions%2F1111111-1111-1111-1111-111111111111%2Fproviders%2FMicrosoft.Resources%2Fdeployments%2Fyourenv-1721867673
421+
422+
(✓) Done: Resource group: yourenv-rg
423+
(✓) Done: Virtual Network: yourenv-e2najjk4vewf2-vnet
424+
(✓) Done: App Service plan: yourenv-e2najjk4vewf2-service-plan
425+
(✓) Done: Log Analytics workspace: yourenv-e2najjk4vewf2-workspace
426+
(✓) Done: Application Insights: yourenv-e2najjk4vewf2-appinsights
427+
(✓) Done: Portal dashboard: yourenv-e2najjk4vewf2-dashboard
428+
(✓) Done: App Service: yourenv-e2najjk4vewf2-app-service
429+
(✓) Done: Azure Database for PostgreSQL flexible server: yourenv-e2najjk4vewf2-postgres-server
430+
(✓) Done: Cache for Redis: yourenv-e2najjk4vewf2-redisCache
431+
(✓) Done: Private Endpoint: cache-privateEndpoint
432+
433+
SUCCESS: Your application was provisioned in Azure in 32 minutes.
434+
You can view the resources created under the resource group yourenv-rg in Azure Portal:
435+
https://portal.azure.com/#@/resource/subscriptions/1111111-1111-1111-1111-111111111111/resourceGroups/yourenv-rg/overview
436+
437+
Deploying services (azd deploy)
438+
439+
(✓) Done: Deploying service web
440+
- Endpoint: https://yourenv-e2najjk4vewf2-app-service.azurewebsites.net/
441+
442+
```
414443

415444
## 2. Examine the database connection string
416445

@@ -432,15 +461,15 @@ Azure App Service requires a startup command to run your FastAPI app. The azd te
432461

433462
:::code language="python" source="~/msdocs-fastapi-postgresql-sample-app/infra/resources.bicep" range="160-178" highlight="12":::
434463

435-
1. The startup command runs the file *src/entrypoint.sh*. Examine the code in that file to understand the commands that App Service runs to start your app:
464+
1. The startup command runs the file *src/entrypoint.sh*. Examine the code in that file to understand the commands that App Service runs to start your app:
436465

437466
:::code language="python" source="~/msdocs-fastapi-postgresql-sample-app/src/entrypoint.sh" range="1-6":::
438467

439468
To learn more about app configuration and startup in App Service, see [Configure a Linux Python app for Azure App Service](configure-language-python.md).
440469

441470
## 4. Generate database schema
442471

443-
You may have noticed in the previous section that *entrypoint.sh* contains the following line: `python3 src/fastapi_app/seed_data.py`. This command migrates your database. In the sample app, it only ensures that the correct tables are created in your database. It doesn't populate these tables with any data.
472+
You might have noticed in the previous section that *entrypoint.sh* contains the following line: `python3 src/fastapi_app/seed_data.py`. This command migrates your database. In the sample app, it only ensures that the correct tables are created in your database. It doesn't populate these tables with any data.
444473
445474
In this section, you'll run this command manually for demonstration purposes. With the PostgreSQL database protected by the virtual network, the easiest way to run the command is in an SSH session with the App Service container.
446475

0 commit comments

Comments
 (0)