Anyone familiar with #Azure #Functions middleware? Trying to run my function app (with http triggers) in a #container and I need CORS middleware to configure a #CORS policy. Functions v4 on dotnet 7 running isolated.
@nikneem @anthonychu might be able to help
@santoshhari @nikneem I think you should be able to set some environment variables. See here: https://github.com/Azure/azure-functions-host/blob/02b161d931e5eeae1d14dc363cafedb4be876c36/src/WebJobs.Script.WebHost/Configuration/HostCorsOptionsSetup.cs
@anthonychu @santoshhari Thanks, going to try this...
@anthonychu @santoshhari I could not get this to work, switched to an ASP Core Web Api that allows me to programmatically set CORS policies. I tried adding the CORS_ALLOWED_ORIGINS setting with an array of allowed hostnames, without result
@nikneem @santoshhari I think there’s another variable to set to get it to execute this code path. Are you happy with ASP.NET Core or would you still prefer to use Functions for this?
@anthonychu @santoshhari well, I'm working on a conference talk demo of microservices in Container Apps, ideally wit a variety of technologies. So yes, getting this to work would be the preferred way to go. If I don't manage to get it done, then web api would be sufficient.
@anthonychu @santoshhari also, I saw this one https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Configuration/CorsOptionsSetup.cs skips CORS config because IsAnyLinuxConsumtion() returns false for container apps (e.g. There is a ContainerName env. var)
@nikneem @santoshhari My head is spinning from reading that logic but I think it requires a variable named CONTAINER_NAME to be set to set up CORS, and that variable isn't created by default on Container Apps.
@anthonychu Victoryyyyyy, I owe you a blog post on this one, thanks for the help
@anthonychu @codesapien Promises promises... https://hexmaster.nl/posts/container-apps-cors-settings/
@nikneem @codesapien Cool. I should add that Container Apps will support CORS similar to App Service and Functions. No ETA though.
@anthonychu @codesapien Obviously, but I need the deployment of certificates through a Key Vault first, or even better.... Managed certificates 😃
But again, thanks for the help
@nikneem @codesapien Hoping to see managed certs in Q1. Key Vault is in backlog but no ETA yet.
@nikneem Awesome! It's still a hack though, as this logic can change and having multiple instances of the host with the same container name might cause issues if there's code that relies on it being unique per instance. I guess if you base your image on a specific version of the host and you test after each upgrade, this is less of a concern.
I've logged a feature request: https://github.com/Azure/azure-functions-host/issues/8936
/cc @codesapien