Azure功能:如何通过自动化设置CORS? [英] Azure Functions: how to set CORS via automation?

查看:111
本文介绍了Azure功能:如何通过自动化设置CORS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure功能应用程序,我想以可重复(自动)的方式进行设置,以便可以在不同的环境/资源组中复制它.我可以通过azure cli创建功能应用程序,但是我还需要配置CORS选项,以便可以从浏览器中调用它.

I have an azure function app that I would like to set up in repeatable (automated) manner so that I can duplicate it in different environments/resource groups. I'm able to create the function app via the azure cli, but I also need to configure the CORS options such that I can call it from a browser.

我已经在azure门户网站的Web ui中找到了在哪里做, 在平台功能"标签中(

I've found where to do that in the azure portal web ui, in the 'Platform Features' tab(https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings#cors), but I can't find anything about modifying that setting via azure cli, or by the VSTS deployment task that I've set up to do releases when I change the functions in the app.

似乎您甚至可以通过local.settisg.json为本地开发指定CORS设置,但这仅在本地适用(

It seems you can even specify the CORS setting for local development via the local.settisg.json, but that only applies locally (https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#local-settings). Were I deploying the app via the azure function tools cli I could supposedly specify the --publish-local-settings flag when I deploy, but I'm not deploying that way.

似乎必须有一种无需使用Web UI即可修改CORS配置的方法,我只是找不到它吗?

It seems like there must be a way to modify the CORS configuration without using the web UI, am I just not finding it?

推荐答案

要以编程方式设置CORS设置,您想使用ARM.

To set CORS settings programatically, you want to use ARM.

以下是您可以遵循的示例: https://msftplayground.com/2016/08/setting-api-definition-url-cors-value-arm/

Here's an example you can follow: https://msftplayground.com/2016/08/setting-api-definition-url-cors-value-arm/

这篇关于Azure功能:如何通过自动化设置CORS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆