Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Override the DEFAULT_FILE_STORAGE with MEDIA_URL to integrate Azure CDN

I'm using Azure Storage account for storing my media files

Setting it is simple in settings.py like this:

DEFAULT_FILE_STORAGE = 'storages.backends.azure_storage.AzureStorage'
AZURE_ACCOUNT_NAME = 'my_account_name'
AZURE_ACCOUNT_KEY = 'my_account_key'
AZURE_CONTAINER = 'my-container'

However, I considered later that I want to use Azure CDN instead for serving my media files. How will I point it to the CDN URL instead? I tried setting it in the MEDIA_URL like

MEDIA_ROOT = os.path.join(BASE_DIR, 'upload')
MEDIA_URL = '//my-media.azureedge.net/my-container/'

However my storage-account blob is the one being shown as default URL which is 'xxxxx.blob.core.windows.net' instead of my MEDIA URL..

How will I show the MEDIA_URL instead of 'xxxxx.blob.core.windows.net'?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Thankfully I already have an answer for this one. You need to override the storage backend class of Azure on the 'storages' library replacing the blob hostname with the CDN hostname.

settings.py

MEDIA_URL = '//my-media.azureedge.net/my-container/'

storages.py

import re
from jaguar import settings
from storages.backends.azure_storage import AzureStorage


class AzureCDNURL(AzureStorage):

    def url(self, name):
        ret = super(AzureCDNURL, self).url(name)
        _ret = re.sub('//[a-z.0-9A-Z]*/', settings.MEDIA_URL, ret)
        return _ret
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda