【问题标题】:Getting error when deployed: An attempt was made to access a socket in a way forbidden by its access permissions部署时出现错误:尝试以访问权限禁止的方式访问套接字
【发布时间】:2020-07-22 15:30:16
【问题描述】:

我在 Go 中创建了一个 Azure 函数。该功能在本地机器上正常工作。但是,当我将其部署到 Azure 时,出现以下异常:

试图以访问权限禁止的方式访问套接字。

内部异常方法为:System.Net.Http.ConnectHelper+<ConnectAsync>d__1.MoveNext

错误日志在这里:https://github.com/mpurusottamc/azurefunc-go/blob/master/errorlog.json

local.settings.json 文件有以下代码:

{
    "IsEncrypted": false,
    "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "node",
        "AzureWebJobsStorage": "<proper storage link>"
    }
}

host.json 文件有 golang 可执行文件引用作为 worker。

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true
            }
        }
    },
    "httpWorker": {
        "description": {
            "defaultExecutablePath": "hello.exe"
        }
    },
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    }
}

我的代码托管在 github 上:https://github.com/mpurusottamc/azurefunc-go

deploy.sh 文件包含部署脚本。

关注了这篇参考文章:https://itnext.io/write-azure-functions-in-any-language-with-the-http-worker-34d01f522bfd

我错过了什么吗?

【问题讨论】:

  • 刚刚试用了您的应用并将其部署到 Windows 消费函数应用,并且可以正常工作。 (需要在部署中添加--force)你使用什么版本的Go编译?有些版本在运行应用程序的 Azure 应用服务沙箱中不起作用。1.14.2 及更高版本应该可以工作。 (我在 macOS 上使用 1.14.5 构建)
  • 如果您在更新 Go 后仍然遇到问题,请在此处提出问题并标记我 (anthonychu)。谢谢! github.com/Azure/azure-functions-host/issues
  • @AnthonyChu 在我将 golang 更新到 1.14 并在部署脚本中应用 --force 之后,它现在可以工作了。感谢您的帮助。

标签: azure go azure-functions socketexception


【解决方案1】:

我在我的机器上将 golang 版本更新为 1.14。并且还在部署脚本中应用了 --force 并为我解决了这个问题。

go.mod 更新如下:

module hello

go 1.14

更新部署脚本以包含 --force 参数

func azure functionapp 发布 hellogoapp --force

【讨论】:

    猜你喜欢
    • 2022-12-15
    • 1970-01-01
    • 2021-02-16
    • 2018-05-24
    • 2016-07-05
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多