Skip to content

Commit a41afee

Browse files
committedMar 2, 2024
sync with autogenerated
1 parent ad915ee commit a41afee

File tree

10 files changed

+33
-52
lines changed

10 files changed

+33
-52
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
__pycache__/
1414
media
1515

16+
# If your build process includes running collectstatic, then you probably don't need
17+
# or want to include staticfiles/ in your Git repository.
18+
src/staticfiles/
1619

1720
### Django.Python Stack ###
1821
# Byte-compiled / optimized / DLL files

‎infra/core/database/mysql/flexibleserver.bicep

+15-30
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,31 @@
1+
metadata description = 'Creates an Azure Database for MySQL - Flexible Server.'
12
param name string
23
param location string = resourceGroup().location
34
param tags object = {}
45

56
param sku object
67
param storage object
7-
@description('Database administrator login name')
8-
@minLength(1)
9-
param adminName string = 'mySqlAdmin'
8+
param administratorLogin string
109
@secure()
11-
param adminPassword string
10+
param administratorLoginPassword string
11+
param highAvailabilityMode string = 'Disabled'
1212
param databaseNames array = []
1313
param allowAzureIPsFirewall bool = false
1414
param allowAllIPsFirewall bool = false
1515
param allowedSingleIPs array = []
1616

17-
@description('MySQL version')
18-
@allowed([
19-
'5.7'
20-
'8.0.21'
21-
])
22-
param version string = '8.0.21'
23-
24-
@allowed([
25-
'Disabled'
26-
'ZoneRedundant'
27-
'SameZone'
28-
])
29-
param highAvailabilityMode string = 'Disabled'
17+
// MySQL version
18+
param version string
3019

31-
resource mysqlServer 'Microsoft.DBforMySQL/flexibleServers@2021-05-01' = {
20+
resource mysqlServer 'Microsoft.DBforMySQL/flexibleServers@2023-06-30' = {
3221
location: location
3322
tags: tags
3423
name: name
3524
sku: sku
3625
properties: {
3726
version: version
38-
administratorLogin: adminName
39-
administratorLoginPassword: adminPassword
27+
administratorLogin: administratorLogin
28+
administratorLoginPassword: administratorLoginPassword
4029
storage: storage
4130
highAvailability: {
4231
mode: highAvailabilityMode
@@ -45,33 +34,29 @@ resource mysqlServer 'Microsoft.DBforMySQL/flexibleServers@2021-05-01' = {
4534

4635
resource database 'databases' = [for name in databaseNames: {
4736
name: name
48-
properties: {
49-
charset: 'utf8'
50-
collation: 'utf8_general_ci'
51-
}
5237
}]
5338

5439
resource firewall_all 'firewallRules' = if (allowAllIPsFirewall) {
5540
name: 'allow-all-IPs'
5641
properties: {
57-
startIpAddress: '0.0.0.0'
58-
endIpAddress: '255.255.255.255'
42+
startIpAddress: '0.0.0.0'
43+
endIpAddress: '255.255.255.255'
5944
}
6045
}
6146

6247
resource firewall_azure 'firewallRules' = if (allowAzureIPsFirewall) {
6348
name: 'allow-all-azure-internal-IPs'
6449
properties: {
65-
startIpAddress: '0.0.0.0'
66-
endIpAddress: '0.0.0.0'
50+
startIpAddress: '0.0.0.0'
51+
endIpAddress: '0.0.0.0'
6752
}
6853
}
6954

7055
resource firewall_single 'firewallRules' = [for ip in allowedSingleIPs: {
7156
name: 'allow-single-${replace(ip, '.', '')}'
7257
properties: {
73-
startIpAddress: ip
74-
endIpAddress: ip
58+
startIpAddress: ip
59+
endIpAddress: ip
7560
}
7661
}]
7762

‎infra/db.bicep

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ module dbserver 'core/database/mysql/flexibleserver.bicep' = {
2222
storageSizeGB: 20
2323
}
2424
version: '8.0.21'
25-
adminName: dbserverUser
26-
adminPassword: dbserverPassword
25+
administratorLogin: dbserverUser
26+
administratorLoginPassword: dbserverPassword
2727
databaseNames: [ dbserverDatabaseName ]
2828
allowAzureIPsFirewall: true
2929
}

‎infra/main.bicep

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ output AZURE_KEY_VAULT_ENDPOINT string = keyVault.outputs.endpoint
138138
output AZURE_KEY_VAULT_NAME string = keyVault.outputs.name
139139
output APPLICATIONINSIGHTS_NAME string = monitoring.outputs.applicationInsightsName
140140

141-
output BACKEND_URI string = web.outputs.uri
141+
output BACKEND_URI string = web.outputs.uri

‎src/.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git*
2+
.venv/
3+
**/*.pyc

‎src/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ COPY entrypoint.sh .
1414
RUN chmod +x entrypoint.sh
1515

1616
COPY . .
17-
CMD bash -c ". entrypoint.sh"
17+
CMD bash -c ". entrypoint.sh"

‎src/project/settings.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
DEBUG = False
3535
DEFAULT_SECRET = None
3636
ALLOWED_HOSTS = [
37-
os.environ["WEBSITE_HOSTNAME"],
37+
os.environ["CONTAINER_APP_NAME"] + "." + os.environ["CONTAINER_APP_ENV_DNS_SUFFIX"],
3838
]
3939
CSRF_TRUSTED_ORIGINS = [
40-
"https://" + os.environ["WEBSITE_HOSTNAME"],
40+
"https://" + os.environ["CONTAINER_APP_NAME"] + "." + os.environ["CONTAINER_APP_ENV_DNS_SUFFIX"],
4141
]
4242

4343
SECRET_KEY = os.environ.get("SECRET_KEY", DEFAULT_SECRET)
@@ -67,9 +67,6 @@
6767
"django.middleware.clickjacking.XFrameOptionsMiddleware",
6868
]
6969

70-
if prod:
71-
MIDDLEWARE.append("opencensus.ext.django.middleware.OpencensusMiddleware")
72-
7370
ROOT_URLCONF = "project.urls"
7471

7572
TEMPLATES = [
@@ -91,16 +88,6 @@
9188
WSGI_APPLICATION = "project.wsgi.application"
9289

9390

94-
OPENCENSUS = {
95-
"TRACE": {
96-
"SAMPLER": "opencensus.trace.samplers.ProbabilitySampler(rate=1)",
97-
"EXPORTER": f"""opencensus.ext.azure.trace_exporter.AzureExporter(
98-
connection_string="{os.environ.get('APPLICATIONINSIGHTS_CONNECTION_STRING')}"
99-
)""",
100-
}
101-
}
102-
103-
# Database
10491
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
10592

10693
db_options = {"ssl_mode": "REQUIRED"}

‎src/project/wsgi.py

+4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99

1010
import os
1111

12+
from azure.monitor.opentelemetry import configure_azure_monitor
1213
from django.core.wsgi import get_wsgi_application
1314

1415
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
1516

17+
if os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"):
18+
configure_azure_monitor()
19+
1620
application = get_wsgi_application()

‎src/requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ django
66
django-crispy-forms
77
crispy-bootstrap4
88
whitenoise
9-
opencensus-ext-azure
10-
opencensus-ext-django
9+
azure-monitor-opentelemetry
1110
mysqlclient

‎src/templates/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<link rel="apple-touch-icon" sizes="120x120" href="{% static 'res/img/favicon-120-precomposed.png' %}">
2525

2626
<!-- Chrome for Android -->
27-
<link rel="manifest" href="{% static 'manifest.json' %}}}">
27+
<link rel="manifest" href="{% static 'manifest.json' %}">
2828
<link rel="icon" sizes="192x192" href="{% static 'res/img/favicon-192.png' %}">
2929

3030
<title>

0 commit comments

Comments
 (0)
Please sign in to comment.