Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 442 forks source link

Custom Headers Not Applied in Azure Function App Settings #10557

Open dellch opened 1 month ago

dellch commented 1 month ago

Is your question related to a specific version? If so, please specify:

Azure Functions (linux) - Runtime version: 4.636.0.0

What language does your question apply to? (e.g. C#, JavaScript, Java, All)

We're using C# - although this may apply to All languages as it relates to the configuration of HTTP headers using host.json and Application Settings.

Question

I am trying to override `host.json values configure custom HTTP headers for my Azure Function App via app settings, but I am not seeing the headers in the HTTP response. I have attempted the following approaches:

  1. Adding a custom header XCustomHeader using the key AzureFunctionsJobHost__extensions__http__customHeaders_XCustomHeader with a value of TestHeaderValue, but this header is not present in the response.

  2. Using key AzureFunctionsJobHost__extensions__http__customHeaders with an escaped JSON as the value

Despite these efforts, none of the custom headers are reflected in the response.

Is there a limitation in how the Azure Functions platform processes these headers when defined in app settings?

Steps to reproduce

  1. Add the following app setting in the Azure Portal using Advanced Edit:
    • Method 1:
      {
        "name": "AzureFunctionsJobHost__extensions__http__customHeaders_XCustomHeader",
        "value": "TestHeaderValue",
        "slotSetting": false
      }
    • Method 2:
      {
        "name": "AzureFunctionsJobHost__extensions__http__customHeaders",
        "value": "{\"Content-Security-Policy\": \"default-src 'self';\", \"Permissions-Policy\": \"accelerometer=(), autoplay=();\"}",
        "slotSetting": false
      }
  2. Save the configuration and restart the Function App.
  3. Navigate to the function app

Expected behavior

The custom headers (XCustomHeader, Content-Security-Policy, etc.) should be present in the HTTP response.

Actual behavior

None of the custom headers are applied to the response

bhagyshricompany commented 4 weeks ago

Hi @dellch Thanks for update as I checked it occurring will update you on this asap.