Follow

Anyone familiar with middleware? Trying to run my function app (with http triggers) in a and I need CORS middleware to configure a policy. Functions v4 on dotnet 7 running isolated.

@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 github.com/Azure/azure-functio 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.

@nikneem Tested it out and it works. Here's my config. Response includes the allow origin header.

@anthonychu Victoryyyyyy, I owe you a blog post on this one, thanks for the help

@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: github.com/Azure/azure-functio

/cc @codesapien

@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 :blobfistbumpL: :blobfistbumpR:

@nikneem @codesapien Hoping to see managed certs in Q1. Key Vault is in backlog but no ETA yet.

Sign in to participate in the conversation
mastodon.cloud

Everyone is welcome as long as you follow our code of conduct! Thank you. Mastodon.cloud is maintained by Sujitech, LLC.