0

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
  • 1,734
  • 4
  • 22
  • 43
  • There is a CORS option in the portal in your function, under "API" just set what you need there – Liam Nov 30 '20 at 13:12
  • @Liam Please read, this is running in a Kubernetes cluster not in the Azure Portal – Lenny D Nov 30 '20 at 13:14
  • The link you provided shows a sample request with a HTTPS (secure) which uses TLS to do an authentication. Since you are using TLS which uses a certificate you may not need a credential so that is why the "*" is used. The CORS error is due to mime attachments (see Wiki : https://en.wikipedia.org/wiki/Cross-origin_resource_sharing). So it looks like the request is working and the mime attachments is being ignored. – jdweng Nov 30 '20 at 13:31
  • @jdweng, my instance is not using TLS at the moment. The link I provided is just the guide I used to get my cluster up and running – Lenny D Nov 30 '20 at 13:33
  • TLS will automatically be used if your URL is HTTPS (not HTTP). A mime attachment looks like the 3 dashes in your request. The mime is a two returns in the body of a message. – jdweng Nov 30 '20 at 13:44
  • @jdweng I don't understand, what requests are you talking about? I haven't provided any urls of my function app. I am not using TLS. The link I provided is just the guide I used it is not my app or my post. My api endpoints are http atm. – Lenny D Nov 30 '20 at 13:47
  • If your real environment doesn't exactly match the guide, then provide information about where it differs. You can't expect us to guess. – ADyson Nov 30 '20 at 14:40
  • 1
    The link you provided is a POST which is a HTTP REQUEST and the sample code in the Link is using HTTPS which automatically uses TLS. – jdweng Nov 30 '20 at 14:42

0 Answers0