Skip to content

Commit 9b62eae

Browse files
committed
Merge changes from main
2 parents fb07985 + 5399177 commit 9b62eae

File tree

10 files changed

+81
-26
lines changed

10 files changed

+81
-26
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10
1+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.12
22

33
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
44
&& apt-get -y install --no-install-recommends postgresql-client \

.devcontainer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This `.devcontainer` directory contains the configuration for a [dev container](
55
The dev container configuration lets you open the repository in a [GitHub codespace](https://docs.github.com/codespaces/overview) or a dev container in Visual Studio Code. For your convenience, the dev container is configured with the following:
66

77
- Python
8+
- Running `pip install -r requirements.txt` from the project at container start.
89
- PostgreSQL
910
- Redis
1011
- [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) (so you can run `azd` commands directly).

.devcontainer/devcontainer.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "python-app-service-postgresql-redis-infra",
33
"dockerComposeFile": "docker-compose.yml",
44
"service": "app",
5-
"workspaceFolder": "/workspace",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
66
"features": {
77
"ghcr.io/azure/azure-dev/azd:latest": {}
88
},
@@ -29,7 +29,6 @@
2929
"password": "app_password"
3030
}
3131
],
32-
"python.pythonPath": "/usr/local/bin/python",
3332
"python.languageServer": "Pylance",
3433
"python.linting.enabled": true,
3534
"python.linting.mypyEnabled": true,
@@ -51,12 +50,10 @@
5150
}
5251
}
5352
},
54-
// Use 'forwardPorts' to make a list of ports inside the container available locally. 5000 is for Flask, 8000 is for Django, and 5432 is for PostgreSQL.
55-
"forwardPorts": [
56-
8000, 5000, 5432
57-
],
53+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
54+
// "forwardPorts": [],
5855
// Use 'postCreateCommand' to run commands after the container is created.
59-
// "postCreateCommand": "",
56+
"postCreateCommand": "pip install -r requirements.txt",
6057
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
6158
"remoteUser": "vscode"
6259
}
File renamed without changes.

.env.sample

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/dependabot.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
- package-ecosystem: "pip" # See documentation for possible values
13+
directory: "/" # Location of package manifests
14+
schedule:
15+
interval: "weekly"

.github/workflows/bicep-audit.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Validate AZD template
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "infra/**"
8+
pull_request:
9+
branches:
10+
- main
11+
paths:
12+
- "infra/**"
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
security-events: write
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Run Microsoft Security DevOps Analysis
25+
uses: microsoft/security-devops-action@preview
26+
id: msdo
27+
continue-on-error: true
28+
with:
29+
tools: templateanalyzer
30+
31+
- name: Upload alerts to Security tab
32+
uses: github/codeql-action/upload-sarif@v3
33+
if: github.repository_owner == 'Azure-Samples'
34+
with:
35+
sarif_file: ${{ steps.msdo.outputs.sarifFile }}

.github/workflows/python-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
# needed because the postgres container does not provide a healthcheck
2626
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
2727
steps:
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2929
- name: Setup python
30-
uses: actions/setup-python@v2
30+
uses: actions/setup-python@v5
3131
with:
3232
python-version: ${{ matrix.python_version }}
3333
architecture: x64

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- azdeveloper
5+
- python
6+
- bicep
7+
- html
8+
products:
9+
- azure
10+
- azure-app-service
11+
- azure-database-postgresql
12+
- azure-virtual-network
13+
urlFragment: msdocs-flask-postgresql-sample-app
14+
name: Deploy a Python (Flask) web app with PostgreSQL in Azure
15+
description: This is a Python web app using the Flask framework and the Azure Database for PostgreSQL relational database service.
16+
---
17+
<!-- YAML front-matter schema: https://review.learn.microsoft.com/en-us/help/contribute/samples/process/onboarding?branch=main#supported-metadata-fields-for-readmemd -->
18+
119
# Deploy a Python (Flask) web app with PostgreSQL in Azure
220

321
This is a Python web app using the Flask framework and the Azure Database for PostgreSQL relational database service. The Flask app is hosted in a fully managed Azure App Service. This app is designed to be be run locally and then deployed to Azure. You can either deploy this project by following the tutorial [*Deploy a Python (Django or Flask) web app with PostgreSQL in Azure*](https://docs.microsoft.com/azure/app-service/tutorial-python-postgresql-app) or by using the [Azure Developer CLI (azd)](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) according to the instructions below.

azureproject/production.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import os
22

3-
# Configure Postgres database based on connection string of the libpq Keyword/Value form
4-
# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
5-
# Uncomment the following lines for App Service
6-
# conn_str = os.environ['AZURE_POSTGRESQL_CONNECTIONSTRING']
7-
# conn_str_params = {pair.split('=')[0]: pair.split('=')[1] for pair in conn_str.split(' ')}
83
# DATABASE_URI = 'postgresql+psycopg2://{dbuser}:{dbpass}@{dbhost}/{dbname}'.format(
9-
# dbuser=conn_str_params['user'],
10-
# dbpass=conn_str_params['password'],
11-
# dbhost=conn_str_params['host'],
12-
# dbname=conn_str_params['dbname']
13-
# )
4+
# dbuser=os.getenv('AZURE_POSTGRESQL_USER'),
5+
# dbpass=os.getenv('AZURE_POSTGRESQL_PASSWORD'),
6+
# dbhost=os.getenv('AZURE_POSTGRESQL_HOST'),
7+
# dbname=os.getenv('AZURE_POSTGRESQL_NAME')
8+
# )

0 commit comments

Comments
 (0)