pulumi-django-azure 1.0.11__tar.gz → 1.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pulumi-django-azure might be problematic. Click here for more details.
- {pulumi_django_azure-1.0.11/src/pulumi_django_azure.egg-info → pulumi_django_azure-1.0.12}/PKG-INFO +79 -2
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/README.md +78 -1
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/pyproject.toml +2 -2
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure/django_deployment.py +10 -2
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12/src/pulumi_django_azure.egg-info}/PKG-INFO +79 -2
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/LICENSE +0 -0
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/setup.cfg +0 -0
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure/__init__.py +0 -0
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure.egg-info/SOURCES.txt +0 -0
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure.egg-info/dependency_links.txt +0 -0
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure.egg-info/requires.txt +0 -0
- {pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure.egg-info/top_level.txt +0 -0
{pulumi_django_azure-1.0.11/src/pulumi_django_azure.egg-info → pulumi_django_azure-1.0.12}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pulumi-django-azure
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: Simply deployment of Django on Azure with Pulumi
|
|
5
5
|
Author-email: Maarten Ureel <maarten@youreal.eu>
|
|
6
6
|
License: MIT License
|
|
@@ -59,9 +59,10 @@ Your Django project should contain a folder `cicd` with these files:
|
|
|
59
59
|
```bash
|
|
60
60
|
python manage.py migrate
|
|
61
61
|
python manage.py collectstatic --noinput
|
|
62
|
+
python manage.py purge_cdn
|
|
62
63
|
gunicorn --timeout 600 --workers $((($NUM_CORES*2)+1)) --chdir $APP_PATH yourapplication.wsgi --access-logfile '-' --error-logfile '-'
|
|
63
64
|
```
|
|
64
|
-
Be sure to change `yourapplication` in the above.
|
|
65
|
+
Be sure to change `yourapplication` in the above. To see the `purge_cdn` management command we use here, see below.
|
|
65
66
|
## Installation
|
|
66
67
|
This package is published on PyPi, so you can just add pulumi-django-azure to your requirements file.
|
|
67
68
|
|
|
@@ -256,6 +257,82 @@ Be sure to configure the SSH key that Azure will use on GitLab side. You can obt
|
|
|
256
257
|
|
|
257
258
|
This would then trigger a redeploy everytime you make a commit to your live branch.
|
|
258
259
|
|
|
260
|
+
## CDN Purging
|
|
261
|
+
We added a management command to Django to purge the CDN cache, and added that to the startup script. Our version is here:
|
|
262
|
+
```python
|
|
263
|
+
import os
|
|
264
|
+
|
|
265
|
+
from azure.mgmt.cdn import CdnManagementClient
|
|
266
|
+
from azure.mgmt.cdn.models import PurgeParameters
|
|
267
|
+
from django.core.management.base import BaseCommand
|
|
268
|
+
|
|
269
|
+
from core.azure_helper import AZURE_CREDENTIAL, get_subscription_id
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class Command(BaseCommand):
|
|
273
|
+
help = "Purges the CDN endpoint"
|
|
274
|
+
|
|
275
|
+
def add_arguments(self, parser):
|
|
276
|
+
parser.add_argument(
|
|
277
|
+
"--wait",
|
|
278
|
+
action="store_true",
|
|
279
|
+
help="Wait for the purge operation to complete",
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
def handle(self, *args, **options):
|
|
283
|
+
# Read environment variables
|
|
284
|
+
resource_group = os.getenv("WEBSITE_RESOURCE_GROUP")
|
|
285
|
+
profile_name = os.getenv("CDN_PROFILE")
|
|
286
|
+
endpoint_name = os.getenv("CDN_ENDPOINT")
|
|
287
|
+
content_paths = ["/*"]
|
|
288
|
+
|
|
289
|
+
# Ensure all required environment variables are set
|
|
290
|
+
if not all([resource_group, profile_name, endpoint_name]):
|
|
291
|
+
self.stderr.write(self.style.ERROR("Missing required environment variables."))
|
|
292
|
+
return
|
|
293
|
+
|
|
294
|
+
# Authenticate with Azure
|
|
295
|
+
cdn_client = CdnManagementClient(AZURE_CREDENTIAL, get_subscription_id())
|
|
296
|
+
|
|
297
|
+
try:
|
|
298
|
+
# Purge the CDN endpoint
|
|
299
|
+
purge_operation = cdn_client.endpoints.begin_purge_content(
|
|
300
|
+
resource_group_name=resource_group,
|
|
301
|
+
profile_name=profile_name,
|
|
302
|
+
endpoint_name=endpoint_name,
|
|
303
|
+
content_file_paths=PurgeParameters(content_paths=content_paths),
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
# Check if the --wait argument was provided
|
|
307
|
+
if options["wait"]:
|
|
308
|
+
purge_operation.result() # Wait for the operation to complete
|
|
309
|
+
self.stdout.write(self.style.SUCCESS("CDN endpoint purge operation completed successfully."))
|
|
310
|
+
else:
|
|
311
|
+
self.stdout.write(self.style.SUCCESS("CDN endpoint purge operation started successfully."))
|
|
312
|
+
|
|
313
|
+
except Exception as e:
|
|
314
|
+
self.stderr.write(self.style.ERROR(f"Error executing CDN endpoint purge command: {e}"))
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
And our azure_helper:
|
|
318
|
+
```python
|
|
319
|
+
from azure.identity import DefaultAzureCredential
|
|
320
|
+
from azure.mgmt.resource import SubscriptionClient
|
|
321
|
+
|
|
322
|
+
# Azure credentials
|
|
323
|
+
AZURE_CREDENTIAL = DefaultAzureCredential()
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def get_db_password() -> str:
|
|
327
|
+
return AZURE_CREDENTIAL.get_token("https://ossrdbms-aad.database.windows.net/.default").token
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def get_subscription_id() -> str:
|
|
331
|
+
subscription_client = SubscriptionClient(AZURE_CREDENTIAL)
|
|
332
|
+
subscriptions = list(subscription_client.subscriptions.list())
|
|
333
|
+
return subscriptions[0].subscription_id
|
|
334
|
+
```
|
|
335
|
+
|
|
259
336
|
## Change requests
|
|
260
337
|
I created this for internal use but since it took me a while to puzzle all the things together I decided to share it.
|
|
261
338
|
Therefore this project is not super generic, but tailored to my needs. I am however open to pull or change requests to improve this project or to make it more usable for others.
|
|
@@ -20,9 +20,10 @@ Your Django project should contain a folder `cicd` with these files:
|
|
|
20
20
|
```bash
|
|
21
21
|
python manage.py migrate
|
|
22
22
|
python manage.py collectstatic --noinput
|
|
23
|
+
python manage.py purge_cdn
|
|
23
24
|
gunicorn --timeout 600 --workers $((($NUM_CORES*2)+1)) --chdir $APP_PATH yourapplication.wsgi --access-logfile '-' --error-logfile '-'
|
|
24
25
|
```
|
|
25
|
-
Be sure to change `yourapplication` in the above.
|
|
26
|
+
Be sure to change `yourapplication` in the above. To see the `purge_cdn` management command we use here, see below.
|
|
26
27
|
## Installation
|
|
27
28
|
This package is published on PyPi, so you can just add pulumi-django-azure to your requirements file.
|
|
28
29
|
|
|
@@ -217,6 +218,82 @@ Be sure to configure the SSH key that Azure will use on GitLab side. You can obt
|
|
|
217
218
|
|
|
218
219
|
This would then trigger a redeploy everytime you make a commit to your live branch.
|
|
219
220
|
|
|
221
|
+
## CDN Purging
|
|
222
|
+
We added a management command to Django to purge the CDN cache, and added that to the startup script. Our version is here:
|
|
223
|
+
```python
|
|
224
|
+
import os
|
|
225
|
+
|
|
226
|
+
from azure.mgmt.cdn import CdnManagementClient
|
|
227
|
+
from azure.mgmt.cdn.models import PurgeParameters
|
|
228
|
+
from django.core.management.base import BaseCommand
|
|
229
|
+
|
|
230
|
+
from core.azure_helper import AZURE_CREDENTIAL, get_subscription_id
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class Command(BaseCommand):
|
|
234
|
+
help = "Purges the CDN endpoint"
|
|
235
|
+
|
|
236
|
+
def add_arguments(self, parser):
|
|
237
|
+
parser.add_argument(
|
|
238
|
+
"--wait",
|
|
239
|
+
action="store_true",
|
|
240
|
+
help="Wait for the purge operation to complete",
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
def handle(self, *args, **options):
|
|
244
|
+
# Read environment variables
|
|
245
|
+
resource_group = os.getenv("WEBSITE_RESOURCE_GROUP")
|
|
246
|
+
profile_name = os.getenv("CDN_PROFILE")
|
|
247
|
+
endpoint_name = os.getenv("CDN_ENDPOINT")
|
|
248
|
+
content_paths = ["/*"]
|
|
249
|
+
|
|
250
|
+
# Ensure all required environment variables are set
|
|
251
|
+
if not all([resource_group, profile_name, endpoint_name]):
|
|
252
|
+
self.stderr.write(self.style.ERROR("Missing required environment variables."))
|
|
253
|
+
return
|
|
254
|
+
|
|
255
|
+
# Authenticate with Azure
|
|
256
|
+
cdn_client = CdnManagementClient(AZURE_CREDENTIAL, get_subscription_id())
|
|
257
|
+
|
|
258
|
+
try:
|
|
259
|
+
# Purge the CDN endpoint
|
|
260
|
+
purge_operation = cdn_client.endpoints.begin_purge_content(
|
|
261
|
+
resource_group_name=resource_group,
|
|
262
|
+
profile_name=profile_name,
|
|
263
|
+
endpoint_name=endpoint_name,
|
|
264
|
+
content_file_paths=PurgeParameters(content_paths=content_paths),
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
# Check if the --wait argument was provided
|
|
268
|
+
if options["wait"]:
|
|
269
|
+
purge_operation.result() # Wait for the operation to complete
|
|
270
|
+
self.stdout.write(self.style.SUCCESS("CDN endpoint purge operation completed successfully."))
|
|
271
|
+
else:
|
|
272
|
+
self.stdout.write(self.style.SUCCESS("CDN endpoint purge operation started successfully."))
|
|
273
|
+
|
|
274
|
+
except Exception as e:
|
|
275
|
+
self.stderr.write(self.style.ERROR(f"Error executing CDN endpoint purge command: {e}"))
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
And our azure_helper:
|
|
279
|
+
```python
|
|
280
|
+
from azure.identity import DefaultAzureCredential
|
|
281
|
+
from azure.mgmt.resource import SubscriptionClient
|
|
282
|
+
|
|
283
|
+
# Azure credentials
|
|
284
|
+
AZURE_CREDENTIAL = DefaultAzureCredential()
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def get_db_password() -> str:
|
|
288
|
+
return AZURE_CREDENTIAL.get_token("https://ossrdbms-aad.database.windows.net/.default").token
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def get_subscription_id() -> str:
|
|
292
|
+
subscription_client = SubscriptionClient(AZURE_CREDENTIAL)
|
|
293
|
+
subscriptions = list(subscription_client.subscriptions.list())
|
|
294
|
+
return subscriptions[0].subscription_id
|
|
295
|
+
```
|
|
296
|
+
|
|
220
297
|
## Change requests
|
|
221
298
|
I created this for internal use but since it took me a while to puzzle all the things together I decided to share it.
|
|
222
299
|
Therefore this project is not super generic, but tailored to my needs. I am however open to pull or change requests to improve this project or to make it more usable for others.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pulumi-django-azure"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.12"
|
|
8
8
|
description = "Simply deployment of Django on Azure with Pulumi"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Maarten Ureel", email = "maarten@youreal.eu" }]
|
|
@@ -27,7 +27,7 @@ Homepage = "https://gitlab.com/MaartenUreel/pulumi-django-azure"
|
|
|
27
27
|
|
|
28
28
|
[tool.poetry]
|
|
29
29
|
name = "pulumi-django-azure"
|
|
30
|
-
version = "1.0.
|
|
30
|
+
version = "1.0.12"
|
|
31
31
|
description = "Simply deployment of Django on Azure with Pulumi"
|
|
32
32
|
authors = ["Maarten Ureel <maarten@youreal.eu>"]
|
|
33
33
|
|
|
@@ -392,11 +392,19 @@ class DjangoDeployment(pulumi.ComponentResource):
|
|
|
392
392
|
return comm_service
|
|
393
393
|
|
|
394
394
|
def _add_webapp_vault(self, administrators: list[str], suffix: str) -> azure.keyvault.Vault:
|
|
395
|
-
# Create a keyvault
|
|
395
|
+
# Create a keyvault with a random suffix to make the name unique
|
|
396
|
+
random_suffix = pulumi_random.RandomString(
|
|
397
|
+
f"vault-suffix-{suffix}",
|
|
398
|
+
# Total length is 24, so deduct the length of the suffix
|
|
399
|
+
length=(24 - 7 - len(suffix)),
|
|
400
|
+
special=False,
|
|
401
|
+
upper=False,
|
|
402
|
+
)
|
|
403
|
+
|
|
396
404
|
vault = azure.keyvault.Vault(
|
|
397
405
|
f"vault-{suffix}",
|
|
398
406
|
resource_group_name=self._rg,
|
|
399
|
-
vault_name=f"vault-{suffix}",
|
|
407
|
+
vault_name=random_suffix.result.apply(lambda r: f"vault-{suffix}-{r}"),
|
|
400
408
|
properties=azure.keyvault.VaultPropertiesArgs(
|
|
401
409
|
tenant_id=self._tenant_id,
|
|
402
410
|
sku=azure.keyvault.SkuArgs(
|
{pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12/src/pulumi_django_azure.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pulumi-django-azure
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: Simply deployment of Django on Azure with Pulumi
|
|
5
5
|
Author-email: Maarten Ureel <maarten@youreal.eu>
|
|
6
6
|
License: MIT License
|
|
@@ -59,9 +59,10 @@ Your Django project should contain a folder `cicd` with these files:
|
|
|
59
59
|
```bash
|
|
60
60
|
python manage.py migrate
|
|
61
61
|
python manage.py collectstatic --noinput
|
|
62
|
+
python manage.py purge_cdn
|
|
62
63
|
gunicorn --timeout 600 --workers $((($NUM_CORES*2)+1)) --chdir $APP_PATH yourapplication.wsgi --access-logfile '-' --error-logfile '-'
|
|
63
64
|
```
|
|
64
|
-
Be sure to change `yourapplication` in the above.
|
|
65
|
+
Be sure to change `yourapplication` in the above. To see the `purge_cdn` management command we use here, see below.
|
|
65
66
|
## Installation
|
|
66
67
|
This package is published on PyPi, so you can just add pulumi-django-azure to your requirements file.
|
|
67
68
|
|
|
@@ -256,6 +257,82 @@ Be sure to configure the SSH key that Azure will use on GitLab side. You can obt
|
|
|
256
257
|
|
|
257
258
|
This would then trigger a redeploy everytime you make a commit to your live branch.
|
|
258
259
|
|
|
260
|
+
## CDN Purging
|
|
261
|
+
We added a management command to Django to purge the CDN cache, and added that to the startup script. Our version is here:
|
|
262
|
+
```python
|
|
263
|
+
import os
|
|
264
|
+
|
|
265
|
+
from azure.mgmt.cdn import CdnManagementClient
|
|
266
|
+
from azure.mgmt.cdn.models import PurgeParameters
|
|
267
|
+
from django.core.management.base import BaseCommand
|
|
268
|
+
|
|
269
|
+
from core.azure_helper import AZURE_CREDENTIAL, get_subscription_id
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class Command(BaseCommand):
|
|
273
|
+
help = "Purges the CDN endpoint"
|
|
274
|
+
|
|
275
|
+
def add_arguments(self, parser):
|
|
276
|
+
parser.add_argument(
|
|
277
|
+
"--wait",
|
|
278
|
+
action="store_true",
|
|
279
|
+
help="Wait for the purge operation to complete",
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
def handle(self, *args, **options):
|
|
283
|
+
# Read environment variables
|
|
284
|
+
resource_group = os.getenv("WEBSITE_RESOURCE_GROUP")
|
|
285
|
+
profile_name = os.getenv("CDN_PROFILE")
|
|
286
|
+
endpoint_name = os.getenv("CDN_ENDPOINT")
|
|
287
|
+
content_paths = ["/*"]
|
|
288
|
+
|
|
289
|
+
# Ensure all required environment variables are set
|
|
290
|
+
if not all([resource_group, profile_name, endpoint_name]):
|
|
291
|
+
self.stderr.write(self.style.ERROR("Missing required environment variables."))
|
|
292
|
+
return
|
|
293
|
+
|
|
294
|
+
# Authenticate with Azure
|
|
295
|
+
cdn_client = CdnManagementClient(AZURE_CREDENTIAL, get_subscription_id())
|
|
296
|
+
|
|
297
|
+
try:
|
|
298
|
+
# Purge the CDN endpoint
|
|
299
|
+
purge_operation = cdn_client.endpoints.begin_purge_content(
|
|
300
|
+
resource_group_name=resource_group,
|
|
301
|
+
profile_name=profile_name,
|
|
302
|
+
endpoint_name=endpoint_name,
|
|
303
|
+
content_file_paths=PurgeParameters(content_paths=content_paths),
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
# Check if the --wait argument was provided
|
|
307
|
+
if options["wait"]:
|
|
308
|
+
purge_operation.result() # Wait for the operation to complete
|
|
309
|
+
self.stdout.write(self.style.SUCCESS("CDN endpoint purge operation completed successfully."))
|
|
310
|
+
else:
|
|
311
|
+
self.stdout.write(self.style.SUCCESS("CDN endpoint purge operation started successfully."))
|
|
312
|
+
|
|
313
|
+
except Exception as e:
|
|
314
|
+
self.stderr.write(self.style.ERROR(f"Error executing CDN endpoint purge command: {e}"))
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
And our azure_helper:
|
|
318
|
+
```python
|
|
319
|
+
from azure.identity import DefaultAzureCredential
|
|
320
|
+
from azure.mgmt.resource import SubscriptionClient
|
|
321
|
+
|
|
322
|
+
# Azure credentials
|
|
323
|
+
AZURE_CREDENTIAL = DefaultAzureCredential()
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def get_db_password() -> str:
|
|
327
|
+
return AZURE_CREDENTIAL.get_token("https://ossrdbms-aad.database.windows.net/.default").token
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def get_subscription_id() -> str:
|
|
331
|
+
subscription_client = SubscriptionClient(AZURE_CREDENTIAL)
|
|
332
|
+
subscriptions = list(subscription_client.subscriptions.list())
|
|
333
|
+
return subscriptions[0].subscription_id
|
|
334
|
+
```
|
|
335
|
+
|
|
259
336
|
## Change requests
|
|
260
337
|
I created this for internal use but since it took me a while to puzzle all the things together I decided to share it.
|
|
261
338
|
Therefore this project is not super generic, but tailored to my needs. I am however open to pull or change requests to improve this project or to make it more usable for others.
|
|
File without changes
|
|
File without changes
|
{pulumi_django_azure-1.0.11 → pulumi_django_azure-1.0.12}/src/pulumi_django_azure/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|