Skip to content

Commit 8c49c7b

Browse files
authored
Merge pull request #17 from Azure-Samples/force-rebuild4
Update from Cruft
2 parents 96fb8b4 + 76fd0a5 commit 8c49c7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+463
-1272
lines changed

.cruft.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator",
3-
"commit": "0f0b48d22b43a060ee42f3055771173518f01729",
3+
"commit": "397605f4143cc348247197e9b1c30729a94b828f",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -11,7 +11,7 @@
1111
"project_host": "appservice",
1212
"web_port": "8000",
1313
"__repo_name": "azure-flask-cosmos-postgres-appservice",
14-
"__src_folder_name": "azure_flask_cosmos_postgres_appservice",
14+
"__src_folder_name": "azure-flask-cosmos-postgres-appservice",
1515
"__project_short_description": "Create a relecloud demo application with flask and cosmos-postgres",
1616
"_copy_without_render": [
1717
".github/workflows/azure-dev.yml",
@@ -30,4 +30,4 @@
3030
}
3131
},
3232
"directory": null
33-
}
33+
}

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
33
{
4-
"name": "azure_flask_cosmos_postgres_appservice",
4+
"name": "azure-flask-cosmos-postgres-appservice",
55

66
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
77
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.

.github/workflows/azure-dev.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
2929
steps:
3030
- name: Checkout
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3232

3333
- name: Install azd
34-
uses: Azure/setup-azd@v0.1.0
34+
uses: Azure/setup-azd@v1.0.0
3535

3636
- name: Log in with Azure (Federated Credentials)
3737
if: ${{ env.AZURE_CLIENT_ID != '' }}

.github/workflows/format.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: Run Python linter and formatter
2+
23
on:
34
push:
4-
branches:
5-
- main
5+
branches: [ main ]
6+
paths-ignore:
7+
- '**.md'
8+
- 'lab/**'
9+
- 'assets/**'
10+
611
pull_request:
7-
branches:
8-
- main
12+
branches: [ main ]
913
paths-ignore:
1014
- '**.md'
1115
- 'lab/**'

.github/workflows/tests.yml

+51-32
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,57 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: ["ubuntu-20.04"]
17+
os: ["ubuntu-latest", "macos-latest", "macos-latest-xlarge", "windows-latest"]
1818
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
19-
services:
20-
db:
21-
image: postgres:14
22-
env:
23-
POSTGRES_PASSWORD: postgres
24-
ports:
25-
- 5432:5432
26-
# needed because the postgres container does not provide a healthcheck
27-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
19+
exclude:
20+
- os: macos-latest-xlarge
21+
python_version: 3.8
22+
- os: macos-latest-xlarge
23+
python_version: 3.9
24+
- os: macos-latest-xlarge
25+
python_version: "3.10"
2826
steps:
29-
- uses: actions/checkout@v3
30-
- name: Setup python
31-
uses: actions/setup-python@v2
32-
with:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
- name: Check for MacOS Runner
30+
if: matrix.os == 'macos-latest-xlarge'
31+
run: brew install postgresql@14
32+
- name: Setup postgres
33+
uses: ikalnytskyi/action-setup-postgres@v4
34+
- name: Setup python
35+
uses: actions/setup-python@v2
36+
with:
3337

34-
python-version: ${{ matrix.python_version }}
35-
architecture: x64
36-
- name: Install dependencies
37-
run: |
38-
python3 -m pip install --upgrade pip
39-
python3 -m pip install -r requirements-dev.txt
40-
playwright install chromium --with-deps
41-
python3 -m pip install -e src
42-
- name: Seed data and run Pytest tests
43-
run: |
44-
python3 -m flask --app src.flaskapp db upgrade --directory src/flaskapp/migrations
45-
python3 -m flask --app src.flaskapp seed --filename src/seed_data.json
46-
python3 -m pytest
47-
env:
48-
POSTGRES_HOST: localhost
49-
POSTGRES_USERNAME: postgres
50-
POSTGRES_PASSWORD: postgres
51-
POSTGRES_DATABASE: postgres
38+
python-version: ${{ matrix.python_version }}
39+
architecture: x64
40+
- name: Install dependencies
41+
run: |
42+
python3 -m pip install --upgrade pip
43+
python3 -m pip install -r requirements-dev.txt
44+
playwright install chromium --with-deps
45+
python3 -m pip install -e src
46+
- name: Seed data
47+
run: |
48+
python3 -m flask --app src.flaskapp db upgrade --directory src/flaskapp/migrations
49+
python3 -m flask --app src.flaskapp seed --filename src/seed_data.json
50+
env:
51+
POSTGRES_HOST: localhost
52+
POSTGRES_USERNAME: postgres
53+
POSTGRES_PASSWORD: postgres
54+
POSTGRES_DATABASE: postgres
55+
- name: Run tests Windows
56+
if: runner.os == 'windows'
57+
run: python3 -m pytest --ignore=src/tests/local/test_gunicorn.py
58+
env:
59+
POSTGRES_HOST: localhost
60+
POSTGRES_USERNAME: postgres
61+
POSTGRES_PASSWORD: postgres
62+
POSTGRES_DATABASE: postgres
63+
- name: Run tests
64+
if: runner.os != 'windows'
65+
run: python3 -m pytest
66+
env:
67+
POSTGRES_HOST: localhost
68+
POSTGRES_USERNAME: postgres
69+
POSTGRES_PASSWORD: postgres
70+
POSTGRES_DATABASE: postgres

README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
# Deploy Flask Application with PostgreSQL via Azure Container Apps
1+
---
2+
page_type: sample
3+
languages:
4+
- azdeveloper
5+
- python
6+
- bicep
7+
- html
8+
- css
9+
- scss
10+
products:
11+
- azure
12+
- azure-app-service
13+
- azure-postgresql
14+
- azure-cosmos-db
15+
urlFragment: azure-flask-cosmos-postgres-appservice
16+
name: Deploy Flask Application with PostgreSQL on Azure App Service (Python)
17+
description: This project deploys a web application for a space travel agency using Flask with Python, and is set up for easy deployment with the Azure Developer CLI.
18+
---
19+
<!-- YAML front-matter schema: https://review.learn.microsoft.com/en-us/help/contribute/samples/process/onboarding?branch=main#supported-metadata-fields-for-readmemd -->
20+
21+
# Deploy Flask Application with PostgreSQL via Azure App Service
222

323
This project deploys a web application for a space travel agency using Flask. The application can be deployed to Azure with Azure App Service using the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview).
424

@@ -52,14 +72,14 @@ python3 -m flask --app src.flaskapp run --debug --reload --port=8000
5272
5373
## Running tests
5474
55-
2. Install the development requirements:
75+
1. Install the development requirements:
5676
5777
```sh
5878
python3 -m pip install -r requirements-dev.txt
5979
python3 -m playwright install chromium --with-deps
6080
```
6181
62-
3. Run the tests:
82+
2. Run the tests:
6383
6484
```sh
6585
python3 -m pytest

infra/core/ai/cognitiveservices.bicep

-38
This file was deleted.

infra/core/database/cosmos/cosmos-account.bicep

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
metadata description = 'Creates an Azure Cosmos DB account.'
12
param name string
23
param location string = resourceGroup().location
34
param tags object = {}
45

6+
@secure()
57
param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING'
68
param keyVaultName string
79

@@ -25,7 +27,7 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = {
2527
databaseAccountOfferType: 'Standard'
2628
enableAutomaticFailover: false
2729
enableMultipleWriteLocations: false
28-
apiProperties: (kind == 'MongoDB') ? { serverVersion: '4.0' } : {}
30+
apiProperties: (kind == 'MongoDB') ? { serverVersion: '4.2' } : {}
2931
capabilities: [ { name: 'EnableServerless' } ]
3032
}
3133
}

infra/core/database/cosmos/mongo/cosmos-mongo-account.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
metadata description = 'Creates an Azure Cosmos DB for MongoDB account.'
12
param name string
23
param location string = resourceGroup().location
34
param tags object = {}

infra/core/database/cosmos/mongo/cosmos-mongo-db.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
metadata description = 'Creates an Azure Cosmos DB for MongoDB account with a database.'
12
param accountName string
23
param databaseName string
34
param location string = resourceGroup().location

infra/core/database/cosmos/sql/cosmos-sql-account.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
metadata description = 'Creates an Azure Cosmos DB for NoSQL account.'
12
param name string
23
param location string = resourceGroup().location
34
param tags object = {}

infra/core/database/cosmos/sql/cosmos-sql-db.bicep

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
metadata description = 'Creates an Azure Cosmos DB for NoSQL account with a database.'
12
param accountName string
23
param databaseName string
34
param location string = resourceGroup().location
@@ -39,7 +40,7 @@ resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15
3940
]
4041
}
4142

42-
module roleDefintion 'cosmos-sql-role-def.bicep' = {
43+
module roleDefinition 'cosmos-sql-role-def.bicep' = {
4344
name: 'cosmos-sql-role-definition'
4445
params: {
4546
accountName: accountName
@@ -56,7 +57,7 @@ module userRole 'cosmos-sql-role-assign.bicep' = [for principalId in principalId
5657
name: 'cosmos-sql-user-role-${uniqueString(principalId)}'
5758
params: {
5859
accountName: accountName
59-
roleDefinitionId: roleDefintion.outputs.id
60+
roleDefinitionId: roleDefinition.outputs.id
6061
principalId: principalId
6162
}
6263
dependsOn: [
@@ -70,4 +71,4 @@ output accountName string = cosmos.outputs.name
7071
output connectionStringKey string = cosmos.outputs.connectionStringKey
7172
output databaseName string = databaseName
7273
output endpoint string = cosmos.outputs.endpoint
73-
output roleDefinitionId string = roleDefintion.outputs.id
74+
output roleDefinitionId string = roleDefinition.outputs.id

infra/core/database/cosmos/sql/cosmos-sql-role-assign.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
metadata description = 'Creates a SQL role assignment under an Azure Cosmos DB account.'
12
param accountName string
23

34
param roleDefinitionId string

infra/core/database/cosmos/sql/cosmos-sql-role-def.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
metadata description = 'Creates a SQL role definition under an Azure Cosmos DB account.'
12
param accountName string
23

34
resource roleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2022-08-15' = {

0 commit comments

Comments
 (0)