azure - Function App 在本地运行良好,但部署到 Azure 时失败

标签 azure go azure-functions

遵循 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

来源链接:https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-other?tabs=go%2Cwindows

使用的绑定(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:

Screenshot of VS Code creating Function App

线索是选择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/

相关文章:

c# - Azure 存储分析日志解析错误

azure - Azure Function 执行上下文中有多少本地磁盘可用

azure - 无法使用 Azure 应用服务上传具有相同指纹错误的公共(public)证书

azure - 限制 ADF 中复印事件的带宽

azure - 如何使用 PowerShell 跨 Azure 订阅列出资源组?

azure - 无法在 Azure Function 中创建编排函数

c# - Azure Function v1 禁止访问云中的存储队列

pointers - 检查指针是否指向 Nil Slice

reactjs - 如何在aws ec2中设置环境变量以进行 react 和进入

postgresql - 没有密码的用户连接到Postgres DB