Azure Functions and CDN - Preserve Origin Hostheader

Julian Hüppauff 336 Reputation points Microsoft Employee
2021-04-23T16:38:58.863+00:00

Hey Folks,

I am trying to create an Azure Function behind CDN. This works like any other function project I had in the past, so no issue here.

When I try to get the Hostname/Domain over which the function was called I always get the function hostname (I expect as it is used as hostheader in the CDN endpoint).
Is there any way I can retrieve the origin hostname / custom domain over which the Azure CDN Endpoint was called?

I am using a C# function at the moment. I tried already to use things like :
req.Headers["x-original-host"]
req.Headers["host"]
etc.

Thanks for the help

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,609 questions
Azure Content Delivery Network
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,786 Reputation points Microsoft Employee
    2021-04-28T22:43:03.237+00:00

    Hello @Julian Hüppauff - Sorry for the late reply. I'm not aware of any headers or any way for Functions to automatically know or maintain the origin hostname value given your scenario. I believe that Azure CDN has to send it explicitly, preferably via headers. With that said, I did come across the following blog post which seems to be achieving the same thing but leveraging DNS configurations to do so: PRESERVING ORIGINAL HOST WITH AZURE CDN AND APP SERVICES

    I'll continue to dig in and update my answer with any new findings.

    0 comments No comments