I had this concern when hosting a static website on Azure Blob Storage using Powershell scripts.
My command was this:
# Define Variables
$RESOURCE_GROUP_NAME = 'myresourcegroup'
$LOCATION = 'northeurope'
$STORAGE_ACCOUNT_NAME = 'mystorageaccount'
$WEBSITE_URL = mywebsite.z16.web.core.windows.net
New-AzCdnEndpoint -ProfileName $STORAGE_ACCOUNT_NAME -ResourceGroupName $RESOURCE_GROUP_NAME -Location $LOCATION -EndpointName $STORAGE_ACCOUNT_NAME -OriginName $STORAGE_ACCOUNT_NAME -OriginHostName $WEBSITE_URL
I ran into the error each time I tried accessing the website using the Azure CDN URL:
The requested URI does not represent any resource on the server
HttpStatusCode: 400
Here's how I fixed it:
I was missing out on the OriginHostHeader
parameter. So I had to add it this time.
# Define Variables
$RESOURCE_GROUP_NAME = 'myresourcegroup'
$LOCATION = 'northeurope'
$STORAGE_ACCOUNT_NAME = 'mystorageaccount'
$WEBSITE_URL = mywebsite.z16.web.core.windows.net
New-AzCdnEndpoint -ProfileName $STORAGE_ACCOUNT_NAME -ResourceGroupName $RESOURCE_GROUP_NAME -Location $LOCATION -EndpointName $STORAGE_ACCOUNT_NAME -OriginName $STORAGE_ACCOUNT_NAME -OriginHostName $WEBSITE_URL -OriginHostHeader $WEBSITE_URL
Note:
The OriginHostName
and the OriginHostHeader
should be of the same value which is the URL of the Azure Storage Container where the website is hosted. In this case it is mywebsite.z16.web.core.windows.net
, and not https://mywebsite.z16.web.core.windows.net/
That's all.
I hope this helps