azure-sdk-for-python: BlobClient returns ClientAuthenticationError when Azure CDN is enabled
- Package Name: azure-storage-blob
- Package Version: 12.10.0
- Operating System: Ubuntu 20.04.4 LTS
- Python Version: 3.9.5
Describe the bug
Calling the BlobClient.exists
method raises a ClientAuthenticationError
when an Azure CDN account URL is used.
To Reproduce Steps to reproduce the behavior:
from azure.storage.blob import BlobServiceClient
ACCOUNT_NAME = "myaccount"
ACCOUNT_KEY = "myaccount-key"
CREDENTIAL = {"account_name": ACCOUNT_NAME, "account_key": ACCOUNT_KEY}
ACCOUNT_URL = f"https://{ACCOUNT_NAME}.blob.core.windows.net"
ACCOUNT_URL_CDN = f"https://{ACCOUNT_NAME}.azureedge.net"
ACCOUNT_URL_CDN_CUSTOM = f"https://static.{ACCOUNT_NAME}.com"
CONTAINER_NAME = "mycontainer"
BLOB_NAME = "path/to/image.png"
# The "standard" blob client endpoint
blob_client = BlobServiceClient(
account_url=ACCOUNT_URL,
credential=CREDENTIAL,
).get_blob_client(
container=CONTAINER_NAME,
blob=BLOB_NAME,
)
# This works! It returns True
blob_client.exists()
# Now, using the Azure CDN blob endpoint
blob_client_cdn = BlobServiceClient(
account_url=ACCOUNT_URL_CDN,
credential=CREDENTIAL,
).get_blob_client(
container=CONTAINER_NAME,
blob=BLOB_NAME,
)
# This does not work, it raises a `ClientAuthenticationError` error
blob_client_cdn.exists()
# Using a custom CDN (which is fully verified)
blob_client_cdn_custom = BlobServiceClient(
account_url=ACCOUNT_URL_CDN_CUSTOM,
credential=CREDENTIAL,
).get_blob_client(
container=CONTAINER_NAME,
blob=BLOB_NAME,
)
# This does not work, it raises a `ClientAuthenticationError` error
blob_client_cdn_custom.exists()
Expected behavior I would expect the client to authenticate correctly when using an Azure CDN or a custom CDN when the client authenticates correctly when using the standard blob endpoint.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 23 (8 by maintainers)
@vincenttran-msft I have generated a few more
RequestID
s for you (just in case you didn’t manage to get to see the others - I guess were a few timezone apart).These were generated using the example code in my original Steps to reproduce the behaviour (with account names and credentials updated).
This issue is preventing us from going live with our project. I would be willing to send you access tokens and keys (which I can recycle, if we do eventually get to go live) so you can reproduce the error yourself.
I have pasted the full output from running my Steps to reproduce the behaviour script if it helps.
I deleted the existing
Microsoft CDN (classic)
CDN, and created a new one with theStandard Verizon
pricing tier. This has resolved the issue.I will mark this issue as closed. Thank you for your time and patience @vincenttran-msft
Thank you @vincenttran-msft
One of the first things I tried was to recycle my keys, I have also tried using SAS tokens - all give the same response, which is correct operation when using the https://myaccount.blob.core.windows.net, but authentication errors when using an Azure CDN endpoint.