Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AZURE_CUSTOM_DOMAIN has no effect on generated URL #1405

Closed
fritzfs opened this issue May 17, 2024 · 2 comments
Closed

AZURE_CUSTOM_DOMAIN has no effect on generated URL #1405

fritzfs opened this issue May 17, 2024 · 2 comments

Comments

@fritzfs
Copy link

fritzfs commented May 17, 2024

Hi!

When I call url property on file, I get the full URL as if I did not set AZURE_CUSTOM_DOMAIN, for example:

https://something.blob.core.windows.net/mediafiles/cache/54/07/54077efe688aecfb1ef32ab868b85717.jpg

I want django-storages to work all operations without a custom domain, but I want this URL with a custom domain that represents my CDN (azure front door).

While debugging azure_storage.py inside django-storages, I see that custom_domain is loaded inside the class and custom_service_client exists, but url method still returns original azure blob url here:

https://github.com/jschneier/django-storages/blob/master/storages/backends/azure_storage.py#L332

I'm using

Python-3.11.0
Django-3.2
Django-Storages 1.14.2
Azure-Storage-Blob 12.19.1

I have the following code in settings.py:

AZURE_CONNECTION_STRING = "..."
AZURE_CONTAINER = "..."
AZURE_CUSTOM_DOMAIN = "blabla.com"
@fritzfs
Copy link
Author

fritzfs commented May 17, 2024

PS, I am aware of this PR and if I understood it correctly, it should work as I described above?
#1176

@fritzfs
Copy link
Author

fritzfs commented May 20, 2024

Found solution!
If we're using AZURE_CUSTOM_DOMAIN, we cannot use AZURE_CONNECTION_STRING because _get_service_client method is not fully executed, see this return:
https://github.com/jschneier/django-storages/blob/master/storages/backends/azure_storage.py#L160

So, instead of using a connection string for auth (https://django-storages.readthedocs.io/en/latest/backends/azure.html#authentication-settings), we used this:

export AZURE_ACCOUNT_NAME=...
export AZURE_ACCOUNT_KEY=...
export AZURE_CUSTOM_DOMAIN=blabla.com
export AZURE_CONTAINER=...

@fritzfs fritzfs closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant