How to upload blob using Azure SDK with a custom domain via Azure CDN and SAS token?

Bathina Mahesh 20 Reputation points
2025-06-04T11:56:31.5566667+00:00

Hi,

I've configured a custom domain on my Azure Storage account using Azure CDN https://learn.microsoft.com/en-us/azure/storage/blobs/storage-custom-domain-name?tabs=azure-portal#using-azure-cdn. I can successfully download files using a SAS token (generated via the Azure Portal and Go SDK) by replacing the storage account domain with the custom domain.

However, when I try to upload a file using the same SAS token, I encounter the following error:

<custom-domain>/testwld-uploads-bucket/validation-1749037452\n--------------------------------------------------------------------------------\nRESPONSE 403: 403 Forbidden\nERROR CODE: AuthenticationFailed\n--------------------------------------------------------------------------------\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\u003cError\u003e\u003cCode\u003eAuthenticationFailed\u003c/Code\u003e\u003cMessage\u003eServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:16b28f3a-501e-004c-2645-d5f9cd000000\nTime:2025-06-04T11:44:12.5605633Z\u003c/Message\u003e\u003cAuthenticationErrorDetail\u003eSignature did not match. String to sign used was acw\n\n2025-06-04T12:14:12Z\n/blob/testwldstorageac/testwld-uploads-bucket/validation-1749037452\nde8a8613-f910-4e33XXXXXXXXXXXXXXXXXX\ne709ae1c-ef4f-432d-a263-a39c33d2c5c1\n2025-06-04T11:44:02Z\n2025-06-04T12:19:02Z\nb\n2025-01-05\n\n\n\n\nhttps\n2025-01-05\nb\n\n\n\nattachment; filename=\"\"\n\n\n\u003c/AuthenticationErrorDetail\u003e\u003c/Error\u003e\n--------------------------------------------------------------------------------\n"

Details:

Able to download via custom domain, upload fails

Upload request returns a 403 AuthenticationFailed error

The request works when using the original Azure storage endpoint

Questions:

Does Azure support uploading via SAS token when using a custom domain through CDN?

If not, is there a recommended approach to securely upload files via a custom domain?

  1. Are there specific configurations needed when uploading with a custom domain?

Thanks in advance for the help.

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
{count} votes

Accepted answer
  1. Hari Babu Vattepally 3,270 Reputation points Microsoft External Staff Moderator
    2025-06-05T18:55:12.6766667+00:00

    Hi @Bathina Mahesh,

    Thanks for the response and providing additional information.

    Does Azure support uploading via SAS token( generated using azure sdk for go https://github.com/Azure/azure-sdk-for-go/blob/sdk/storage/azblob/v1.6.0/sdk/storage/azblob/sas/examples_test.go#L31 ) when using a custom domain through Azure Front door?

    Yes, Azure supports uploading and downloading via SAS token when using a custom domain through Azure Front door only if the SAS token is correctly generated by using the original Azure blob storage endpoint for example: https://<account>.blob.core.windows.net.

    Whenever you are generating SAS token, use the storage account domain instead of custom domain. Example as below:

    endpointURL := "https://testwldstorageac.blob.core.windows.net"
    

    So once the SAS token has been generated, replace the domain with the custom domain for accessing the blob.

    Also, please make sure that there are proper SAS tokens permissions are provided like Read, Write, Create and Add permissions. Check and correct the expiration time to avoid authentication failures.

    Please make sure that the request headers are passed unchanged by configuring Azure Front Door rules which may also modifies headers, causes authentication issues.

    For more information, please refer the below document:

    Reliable file upload to Azure Storage Blob through Azure Front Door.

    Hope this helps!

    Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.