Pamela Fox commited on
Commit
79d1118
·
2 Parent(s): 77aeaf0 41dfb58

Merge branch 'main' of github.com:pamelafox/django-quiz-app

Browse files
Files changed (4) hide show
  1. README.md +25 -11
  2. infra/main.bicep +2 -5
  3. infra/main.parameters.json +0 -3
  4. requirements.txt +2 -2
README.md CHANGED
@@ -88,21 +88,35 @@ The same tests are also run as a Github action.
88
 
89
  ## Deployment
90
 
91
- This repository is set up for deployment on Azure App Service (w/PostGreSQL flexible server) using the configuration files in the `infra` folder.
92
 
93
- 1. Sign up for a [free Azure account](https://azure.microsoft.com/free/?WT.mc_id=python-79461-pamelafox)
94
- 2. Install the [Azure Dev CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd?WT.mc_id=python-79461-pamelafox). (If you open this repository in Codespaces or with the VS Code Dev Containers extension, that part will be done for you.)
95
- 3. Provision and deploy all the resources:
96
 
97
- ```
98
- azd up
99
- ```
100
 
101
- 4. To be able to access `/admin`, you'll need a Django superuser. Navigate to the Azure Portal for the App Service, select SSH, and run this command:
102
 
103
- ```
104
- python manage.py createsuperuser
105
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  ### CI/CD pipeline
108
 
 
88
 
89
  ## Deployment
90
 
91
+ This repository is set up for deployment on Azure App Service (w/PostgreSQL flexible server) using the configuration files in the `infra` folder.
92
 
93
+ 1. Sign up for a [free Azure account](https://azure.microsoft.com/free/)
94
+ 2. Install the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd). (If you open this repository in Codespaces or with the VS Code Dev Containers extension, that part will be done for you.)
95
+ 3. Login to Azure:
96
 
97
+ ```shell
98
+ azd auth login
99
+ ```
100
 
101
+ 4. Provision and deploy all the resources:
102
 
103
+ ```shell
104
+ azd up
105
+ ```
106
+
107
+ It will prompt you to provide an `azd` environment name (like "django-app"), select a subscription from your Azure account, and select a location (like "eastus"). Then it will provision the resources in your account and deploy the latest code. If you get an error with deployment, changing the location can help, as there may be availability constraints for some of the resources.
108
+
109
+ 5. To be able to access `/admin`, you'll need a Django superuser. Navigate to the Azure Portal for the App Service, select SSH, and run this command:
110
+
111
+ ```
112
+ python manage.py createsuperuser
113
+ ```
114
+
115
+ 6. When you've made any changes to the app code, you can just run:
116
+
117
+ ```shell
118
+ azd deploy
119
+ ```
120
 
121
  ### CI/CD pipeline
122
 
infra/main.bicep CHANGED
@@ -9,10 +9,6 @@ param name string
9
  @description('Primary location for all resources')
10
  param location string
11
 
12
- @secure()
13
- @description('PostGreSQL Server administrator username')
14
- param postgresAdminUser string
15
-
16
  @secure()
17
  @description('PostGreSQL Server administrator password')
18
  param postgresAdminPassword string
@@ -24,6 +20,7 @@ param principalId string = ''
24
  @description('Django SECRET_KEY for cryptographic signing')
25
  param djangoSecretKey string
26
 
 
27
  var resourceToken = toLower(uniqueString(subscription().id, name, location))
28
  var tags = { 'azd-env-name': name }
29
 
@@ -36,7 +33,7 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
36
  var prefix = '${name}-${resourceToken}'
37
 
38
  var postgresServerName = '${prefix}-postgresql'
39
-
40
  var postgresDatabaseName = 'django'
41
 
42
  module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
 
9
  @description('Primary location for all resources')
10
  param location string
11
 
 
 
 
 
12
  @secure()
13
  @description('PostGreSQL Server administrator password')
14
  param postgresAdminPassword string
 
20
  @description('Django SECRET_KEY for cryptographic signing')
21
  param djangoSecretKey string
22
 
23
+
24
  var resourceToken = toLower(uniqueString(subscription().id, name, location))
25
  var tags = { 'azd-env-name': name }
26
 
 
33
  var prefix = '${name}-${resourceToken}'
34
 
35
  var postgresServerName = '${prefix}-postgresql'
36
+ var postgresAdminUser = 'admin${uniqueString(resourceGroup.id)}'
37
  var postgresDatabaseName = 'django'
38
 
39
  module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
infra/main.parameters.json CHANGED
@@ -11,9 +11,6 @@
11
  "principalId": {
12
  "value": "${AZURE_PRINCIPAL_ID}"
13
  },
14
- "postgresAdminUser": {
15
- "value": "$(secretOrRandomPassword ${AZURE_KEY_VAULT_NAME} postgresAdminUser)"
16
- },
17
  "postgresAdminPassword": {
18
  "value": "$(secretOrRandomPassword ${AZURE_KEY_VAULT_NAME} postgresAdminPassword)"
19
  },
 
11
  "principalId": {
12
  "value": "${AZURE_PRINCIPAL_ID}"
13
  },
 
 
 
14
  "postgresAdminPassword": {
15
  "value": "$(secretOrRandomPassword ${AZURE_KEY_VAULT_NAME} postgresAdminPassword)"
16
  },
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- Django==4.1.7
2
- psycopg2==2.9.5
3
  python-dotenv==1.0.0
4
  whitenoise[brotli]==6.4.0
 
1
+ Django==4.2
2
+ psycopg2==2.9.6
3
  python-dotenv==1.0.0
4
  whitenoise[brotli]==6.4.0