CORS Issue with Azure Functions inside AKS Cluster

11/30/2020

I have a AKS Cluster in Azure which is running my Azure functions project. I got it working by following this guide.

https://markheath.net/post/azure-functions-aks-keda

The service is running, however any requests from my site fail with a CORS error. If you notice on the guide the CORS option is set to * in the local.settings.json file.

I noticed that azure functions does not seem to read the local.settings.json or settings.json files when running inside a container.

I am not sure why but to get it running locally I had to set the connection strings as environment variables.

It looks like the func kubernetetes deploy --dry-run > deploy.yml does the same, as the yaml looks something like this:

data:
  AzureWebJobsStorage: ConnectionStringHere
  AzureSignalRConnectionString:  ConnectionStringHere
  AzureBlobStorage:  ConnectionStringHere 
  FUNCTIONS_WORKER_RUNTIME: ZG90bmV0
  FUNCTIONS_V2_COMPATIBILITY_MODE: dHJ1ZQ==
apiVersion: v1
kind: Secret
metadata:
  name: my-app-live
  namespace: default
---
apiVersion: v1 

Note, there is no reference to CORS in there at all, even against the LoadBalancer.

I have done some research and it looks like others change the load balancer to nginx as a reverse proxy to deal with this. I am not sure this an option for me or what the repercussions would be as this is using DurableFunctions and KEDA for scaling and I don't want to do anything that might break that functionality.

The FunctionApp is written in C#

I am very new to Kubernetes so please give as much detail as possible if you can help.

-- Lenny D
azure-functions
c#
keda
kubernetes

0 Answers