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

Can't get private azure blob #948

Open
sdhunna21 opened this issue Oct 23, 2020 · 4 comments
Open

Can't get private azure blob #948

sdhunna21 opened this issue Oct 23, 2020 · 4 comments

Comments

@sdhunna21
Copy link

I have django-storages working fine with azure blob storage if I set the container access level to blob anonymous. If I change the container access level to private, I can still upload files, however when I attempt to get them, I get an XML message that says ResourceNotFound.

In the documentation the only change I think I need to make in the settings is to have a value for AZURE_URL_EXPIRATION_SECS. I've set it to 600. The URL I see in the address bar is the same as it was for public blob. I thought it would be a temporary looking url.

Here's the full error:

<Error>
<Code>ResourceNotFound</Code>
<Message>The specified resource does not exist. RequestId:bb948def-801e-0051-474f-a96d6e000000 Time:2020-10-23T15:18:33.7048784Z</Message>
</Error>

Here are my settings (with my data removed):

DEFAULT_FILE_STORAGE = 'storages.backends.azure_storage.AzureStorage'
AZURE_ACCOUNT_NAME = "<my account>"
AZURE_CUSTOM_DOMAIN = f'{AZURE_ACCOUNT_NAME}.blob.core.windows.net'
AZURE_ACCOUNT_KEY = "<my key>"
AZURE_CONTAINER = "<my cont>"
MEDIA_URL = f'https://{AZURE_CUSTOM_DOMAIN}/{AZURE_CONTAINER}/'
AZURE_URL_EXPIRATION_SECS = '600'

Here are the versions I'm using:

django-storages==1.10.1
Django==3.1.2
azure-common==1.1.25
azure-storage-blob==2.1.0
azure-storage-common==2.1.0
@BarkaviSJ
Copy link

@sdhunna21
I am also trying to access private blob in my django app. It worked as intended when the access level to my blob was anonymous. Could you suggest the changes if you have made it to work?

Thank you.

@esskaey
Copy link

esskaey commented May 6, 2021

Having the same issue as well. Only works with blob access anonymous.

@nitely
Copy link
Contributor

nitely commented Jan 9, 2022

I suspect this is because you are using a string for the expiration instead of a int.
Try replacing

AZURE_URL_EXPIRATION_SECS = '600'

by

AZURE_URL_EXPIRATION_SECS = 600

If you don't want to use the account key, you need to set the AZURE_TOKEN_CREDENTIAL setting (#1063), or the AZURE_SAS_TOKEN setting. This may be needed, not sure.

@OfficerWhiff
Copy link

I suspect this is because you are using a string for the expiration instead of a int. Try replacing

AZURE_URL_EXPIRATION_SECS = '600'

by

AZURE_URL_EXPIRATION_SECS = 600

If you don't want to use the account key, you need to set the AZURE_TOKEN_CREDENTIAL setting (#1063), or the AZURE_SAS_TOKEN setting. This may be needed, not sure.

This saved me!! @nitely Huge thanks!!

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

5 participants