遵循 Microsoft Function App with Go 快速入门 ( https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-other?tabs=go%2Cwindows )
我能够在我的 Windows 计算机上本地成功运行代码。我继续按照步骤将 Function App 部署到 Azure 门户,并尝试在/api/HttpExample 端点运行 Function App。即使在本地运行良好,也会执行失败。
使用的编程语言:Go 1.17.7
使用的绑定(bind)
最佳答案
我遇到了同样的问题(在本地工作,部署时无法加载),但我在本地运行 Linux。我收到的错误消息是:
An attempt was made to access a socket in a way forbidden by its access permissions.
我是通过 VS Code Azure 扩展创建 Azure Function App,创建 Function App 时的默认操作系统是 Windows:
线索是选择Advanced
选项并选择OS->Linux。使用 AZ CLI,您需要添加选项 --os-type Linux
,例如:
az functionapp create --os-type Linux --resource-group hellogorgplinux --consumption-plan-location eastus --runtime node --runtime-version 10 --functions-version 3 --name hellogoapplinux --storage-account hellogostglinux
关于azure - Function App 在本地运行良好,但部署到 Azure 时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71571157/