Skip to content

Commit 132589c

Browse files
Merge pull request #248685 from alexwolfmsft/revert-pivots
remove azd flow
2 parents e99bb25 + 744b159 commit 132589c

File tree

2 files changed

+0
-266
lines changed

2 files changed

+0
-266
lines changed

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

Lines changed: 0 additions & 257 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ms.topic: tutorial
66
ms.date: 02/28/2023
77
ms.author: msangapu
88
ms.custom: mvc, seodec18, seo-python-october2019, cli-validate, devx-track-python, devdivchpfy22, event-tier1-build-2022, vscode-azure-extension-update-completed, AppServiceConnectivity
9-
zone_pivot_groups: deploy-python-web-app-postgresql
109
---
1110

1211
# Deploy a Python (Django or Flask) web app with PostgreSQL in Azure
@@ -20,8 +19,6 @@ In this tutorial, you'll deploy a data-driven Python web app (**[Django](https:/
2019
* An Azure account with an active subscription. If you don't have an Azure account, you [can create one for free](https://azure.microsoft.com/free/python).
2120
* Knowledge of Python with Flask development or [Python with Django development](/training/paths/django-create-data-driven-websites/)
2221

23-
:::zone pivot="deploy-portal"
24-
2522
## Sample application
2623

2724
Sample Python applications using the Flask and Django framework are provided to help you follow along with this tutorial. To deploy them without running them locally, skip this part.
@@ -519,260 +516,6 @@ If you can't connect to the SSH session, then the app itself has failed to start
519516

520517
If you encounter any errors related to connecting to the database, check if the app settings (`AZURE_POSTGRESQL_CONNECTIONSTRING`) have been changed. Without that connection string, the migrate command can't communicate with the database.
521518

522-
:::zone-end
523-
524-
:::zone pivot="deploy-azd"
525-
526-
## Provision and deploy using the Azure Developer CLI
527-
528-
Sample Python application templates using the Flask and Django framework are provided for this tutorial. The [Azure Developer CLI](/azure/developer/azure-developer-cli/overview) greatly streamlines the process of provisioning application resources and deploying code on Azure. For a more step-by-step approach using the Azure portal and other tools, toggle to the **Azure portal** approach at the top of the page.
529-
530-
The Azure Developer CLI (azd) provides end-to-end support for project initialization, provisioning, deploying, monitoring and scaffolding a CI/CD pipeline to run against real Azure resources. You can use `azd` to provision and deploy the resources for the sample application in an automated and streamlined way.
531-
532-
Follow the steps below to setup the Azure Developer CLI and provision and deploy the sample application:
533-
534-
1. Install the Azure Developer CLI. For a full list of supported installation options and tools, visit the [installation guide](/azure/developer/azure-developer-cli/install-azd).
535-
536-
### [Windows](#tab/windows)
537-
538-
```azdeveloper
539-
powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"
540-
```
541-
542-
### [macOS/Linux](#tab/mac-linux)
543-
544-
```azdeveloper
545-
curl -fsSL https://aka.ms/install-azd.sh | bash
546-
```
547-
548-
---
549-
550-
1. Run the `azd init` command to initialize the `azd` app template. Include the `--template` parameter to specify the name of an existing `azd` template you wish to use. More information about working with templates is available on the [choose an `azd` template](/azure/developer/azure-developer-cli/azd-templates) page.
551-
552-
### [Flask](#tab/flask)
553-
554-
For this tutorial, Flask users should specify the [Python (Flask) web app with PostgresSQL](https://github.com/Azure-Samples/msdocs-flask-postgresql-sample-app.git) template.
555-
556-
```bash
557-
azd init --template msdocs-flask-postgresql-sample-app
558-
```
559-
560-
### [Django](#tab/django)
561-
562-
For this tutorial, Django users should specify the [Python (Django) web app with PostgresSQL](https://github.com/Azure-Samples/msdocs-django-postgresql-sample-app.git) template.
563-
564-
```bash
565-
azd init --template msdocs-django-postgresql-sample-app
566-
```
567-
568-
1. Run the `azd auth login` command to sign-in to Azure.
569-
570-
```bash
571-
azd auth login
572-
```
573-
574-
1. Run the `azd up` command to provision the necessary Azure resources and deploy the app code. The `azd up` command will also prompt you to select the desired subscription and location to deploy to.
575-
576-
```bash
577-
azd up
578-
```
579-
580-
1. When the `azd up` command finishes running, the URL for your deployed web app in the console will be printed. Click, or copy and paste the web app URL into your browser to explore the running app and verify that it is working correctly. All of the Azure resources and application code were set up for you by the `azd up` command.
581-
582-
The name of the resource group that was created is also displayed in the console output. Locate the resource group in the Azure portal to see all of the provisioned resources.
583-
584-
:::image type="content" border="False" source="./media/tutorial-python-postgresql-app/azd-resources-small.png" lightbox="./media/tutorial-python-postgresql-app/azd-resources.png" alt-text="A screenshot showing the resources deployed by the Azure Developer CLI.":::
585-
586-
The Azure Developer CLI also enables you to configure your application to use a CI/CD pipeline for deployments, setup monitoring functionality, and even remove the provisioned resources if you want to tear everything down. For more information about these additional workflows, visit the project [README](https://github.com/Azure-Samples/msdocs-flask-postgresql-sample-app/blob/main/README.md).
587-
588-
## Explore the completed azd project template workflow
589-
590-
The sections ahead review the steps that `azd` handled for you in more depth. You can explore this workflow to better understand the requirements for deploying your own apps to Azure. When you ran `azd up`, the Azure Developer CLI completed the following steps:
591-
592-
> [!NOTE]
593-
> You can also use the steps outlined in the **Azure portal** version of this flow to gain additional insights into the tasks that `azd` completed for you.
594-
595-
### 1. Cloned and initialized the project
596-
597-
The `azd init` command cloned the sample app project template to your machine. The project template includes the following components:
598-
599-
* **Source code**: The code and assets for a Flask or Django web app that can be used for local development or deployed to Azure.
600-
* **Bicep files**: Infrastructure as code (IaC) files that are used by `azd` to create the necessary resources in Azure.
601-
* **Configuration files**: Essential configuration files such as `azure.yaml` that are used by `azd` to provision, deploy and wire resources together to produce a fully fledged application.
602-
603-
### 2. Provisioned the Azure resources
604-
605-
The `azd up` command created all of the resources for the sample application in Azure using the Bicep files in the [`infra`](https://github.com/Azure-Samples/msdocs-flask-postgresql-sample-app/tree/main/infra) folder of the project template. [Bicep](/azure/azure-resource-manager/bicep/overview?tabs=bicep) is a declarative language used to manage Infrastructure as Code in Azure. Some of the key resources and configurations created by the template include:
606-
607-
* **Resource group**: A resource group was created to hold all of the other provisioned Azure resources. The resource group keeps your resources well organized and easier to manage. The name of the resource group is based off of the environment name you specified during the `azd up` initialization process.
608-
* **Azure Virtual Network**: A virtual network was created to enable the provisioned resources to securely connect and communicate with one another. Related configurations such as setting up a private DNS zone link were also applied.
609-
* **Azure App Service plan**: An App Service plan was created to host App Service instances. App Service plans define what compute resources are available for one or more web apps.
610-
* **Azure App Service**: An App Service instance was created in the new App Service plan to host and run the deployed application. In this case a Linux instance was created and configured to run Python apps. Additional configurations were also applied to the app service, such as setting the Postgres connection string and secret keys.
611-
* **Azure Database for PostgreSQL**: A Postgres database and server were created for the app hosted on App Service to connect to. The required admin user, network and connection settings were also configured.
612-
* **Azure Application Insights**: Application insights was set up and configured for the app hosted on the App Service. This service enables detailed telemetry and monitoring for your application.
613-
614-
You can inspect the Bicep files in the [`infra`](https://github.com/Azure-Samples/msdocs-flask-postgresql-sample-app/tree/main/infra) folder of the project to understand how each of these resources were provisioned in more detail. The `resources.bicep` file defines most of the different services created in Azure. For example, the App Service plan and App Service web app instance were created and connected using the following Bicep code:
615-
616-
### [Flask](#tab/flask)
617-
618-
```yaml
619-
resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
620-
name: '${prefix}-service-plan'
621-
location: location
622-
tags: tags
623-
sku: {
624-
name: 'B1'
625-
}
626-
properties: {
627-
reserved: true
628-
}
629-
}
630-
631-
resource web 'Microsoft.Web/sites@2022-03-01' = {
632-
name: '${prefix}-app-service'
633-
location: location
634-
tags: union(tags, { 'azd-service-name': 'web' })
635-
kind: 'app,linux'
636-
properties: {
637-
serverFarmId: appServicePlan.id
638-
siteConfig: {
639-
alwaysOn: true
640-
linuxFxVersion: 'PYTHON|3.10'
641-
ftpsState: 'Disabled'
642-
appCommandLine: 'startup.sh'
643-
}
644-
httpsOnly: true
645-
}
646-
identity: {
647-
type: 'SystemAssigned'
648-
}
649-
```
650-
651-
### [Django](#tab/django)
652-
653-
```yml
654-
resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
655-
name: '${prefix}-service-plan'
656-
location: location
657-
tags: tags
658-
sku: {
659-
name: 'B1'
660-
}
661-
properties: {
662-
reserved: true
663-
}
664-
}
665-
666-
resource web 'Microsoft.Web/sites@2022-03-01' = {
667-
name: '${prefix}-app-service'
668-
location: location
669-
tags: union(tags, { 'azd-service-name': 'web' })
670-
kind: 'app,linux'
671-
properties: {
672-
serverFarmId: appServicePlan.id
673-
siteConfig: {
674-
alwaysOn: true
675-
linuxFxVersion: 'PYTHON|3.10'
676-
ftpsState: 'Disabled'
677-
appCommandLine: 'startup.sh'
678-
}
679-
httpsOnly: true
680-
}
681-
identity: {
682-
type: 'SystemAssigned'
683-
}
684-
685-
```
686-
687-
---
688-
689-
The Azure Database for PostgreSQL was also created using the following Bicep:
690-
691-
```yml
692-
resource postgresServer 'Microsoft.DBforPostgreSQL/flexibleServers@2022-01-20-preview' = {
693-
location: location
694-
tags: tags
695-
name: pgServerName
696-
sku: {
697-
name: 'Standard_B1ms'
698-
tier: 'Burstable'
699-
}
700-
properties: {
701-
version: '12'
702-
administratorLogin: 'postgresadmin'
703-
administratorLoginPassword: databasePassword
704-
storage: {
705-
storageSizeGB: 128
706-
}
707-
backup: {
708-
backupRetentionDays: 7
709-
geoRedundantBackup: 'Disabled'
710-
}
711-
network: {
712-
delegatedSubnetResourceId: virtualNetwork::databaseSubnet.id
713-
privateDnsZoneArmResourceId: privateDnsZone.id
714-
}
715-
highAvailability: {
716-
mode: 'Disabled'
717-
}
718-
maintenanceWindow: {
719-
customWindow: 'Disabled'
720-
dayOfWeek: 0
721-
startHour: 0
722-
startMinute: 0
723-
}
724-
}
725-
726-
dependsOn: [
727-
privateDnsZoneLink
728-
]
729-
}
730-
```
731-
732-
### 3. Deployed the application
733-
734-
The `azd up` command also deployed the sample application code to the provisioned Azure resources. The Developer CLI understands how to deploy different parts of your application code to different services in Azure using the `azure.yaml` file at the root of the project. The `azure.yaml` file specifies the app source code location, the type of app, and the Azure Service that should host that app.
735-
736-
Consider the following `azure.yaml` file. These configurations tell the Azure Developer CLI that the Python code that lives at the root of the project should be deployed to the created App Service.
737-
738-
### [Flask](#tab/flask)
739-
740-
```yml
741-
name: flask-postgresql-sample-app
742-
metadata:
743-
744-
services:
745-
web:
746-
project: .
747-
language: py
748-
host: appservice
749-
```
750-
751-
### [Django](#tab/django)
752-
753-
```yml
754-
name: django-postgresql-sample-app
755-
metadata:
756-
757-
services:
758-
web:
759-
project: .
760-
language: py
761-
host: appservice
762-
```
763-
764-
---
765-
766-
## Remove the resources
767-
768-
Once you are finished experimenting with your sample application, you can run the `azd down` command to remove the app from Azure. Removing resources helps to avoid unintended costs or unused services in your Azure subscription.
769-
770-
```bash
771-
azd down
772-
```
773-
774-
:::zone-end
775-
776519
## Frequently asked questions
777520

778521
- [How much does this setup cost?](#how-much-does-this-setup-cost)

articles/zone-pivot-groups.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,15 +2563,6 @@ groups:
25632563
title: Microsoft Graph PowerShell
25642564
- id: ms-graph
25652565
title: Microsoft Graph
2566-
# Owner:
2567-
- id: deploy-python-web-app-postgresql
2568-
title: Workflows
2569-
prompt: Choose your path
2570-
pivots:
2571-
- id: deploy-portal
2572-
title: Azure portal
2573-
- id: deploy-azd
2574-
title: Azure Developer CLI
25752566
# Owner: daknappe (Azure Virtual Desktop)
25762567
- id: azure-virtual-desktop-host-pool-types
25772568
title: Azure Virtual Desktop host pool management type

0 commit comments

Comments
 (0)