Enable CORS when running Azure Functions Project Locally

We can run Azure Functions locally during development now with the Azure Functions tooling in the latest version of Visual Studio 2017. In order to call these functions from another project, I needed to enable CORS which took me a minute to figure out. There may be a better way of doing this to come, but this did the trick for right now.

  • Go to the Properties of your Azure Functions project (Right click the project -> Properties)
  • Click on the Debug tab
  • Add the following to the Application arguments section:

EnableCORSAzureFunctions

You can also add this to your current profile in the launchSettings.json file.

{
"profiles": {
"Functions": {
"commandName": "Project",
"commandLineArgs": "host start --cors http://localhost:1909"
}
}
}

This did the trick for me..for now! Hopefully it helps you too.

Leave a comment