【Azure Function】Function App启动时出现 Failed to open local port 4001 错误,这是什么情况呢?

简介: 【Azure Function】Function App启动时出现 Failed to open local port 4001 错误,这是什么情况呢?

问题描述

在使用Azure Function时,启用了多个槽(slot),方便在部署生产环境的时候直接切换。

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "Schedule_Timer": "*/30 * * * * *"
  }
}

在使用C#进程外模式( dotnet-isolated )分别部署了生产槽和预生产槽后,发现预生产槽的Function启动日志中,由警告错误端口启用的消息:

ExtensionWarningEvent -- Failed to open local port 4001. This was attempt #1 to open a local port.

对比可以正常运行的生产槽日志,就是

[Information] Opened local gRPC endpoint: http://localhost:4001. InstanceId: . Function: . HubName:fun001slot. AppName: fun001. SlotName: 2ndslot. ExtensionVersion: 2.13.0. SequenceNumber: 0.

这个4001端口,是什么情况呢?

 

问题解答

端口 4001 用于与进程外模式(dotnet-isolated)的 gRPC 进程间通信的。

Function在运行的时候,会首先尝试绑定到 4001端口,因此它可能在大多数情况下都能正常绑定。但是,当该端口被占用时,它将开始尝试获取 30000 - 31000 范围内的随机端口。继续查看Failed to open local port 4001之后的日志,就可以发现它第二次尝试的时候,已经改变端口并绑定成功。

1)Failed to open local port 4001. This was attempt #1 to open a local port.. InstanceId: . Function: . HubName: fun001slot. AppName: fun001. SlotName: 2ndslot. ExtensionVersion: 2.13.0. SequenceNumber: 0.

2)Opened local gRPC endpoint: http://localhost:30721. InstanceId: . Function: . HubName: fun001slot. AppName: fun001. SlotName: 2ndslot. ExtensionVersion: 2.13.0. SequenceNumber: 1.

 

所以,这个错误只是一个警告。并不会影响Funciton的正常运行。

 

参考资料

Change Grpc port #145 : https://github.com/microsoft/durabletask-dotnet/issues/145

The functions extension code will first attempt to bind to 4001, so it may work for you most of the time. But when that port is reserved it will start trying to get random ports in the 30000 to 31000 range.  

相关文章
|
6月前
|
API C++
【Azure 环境】VS Code登录China Azure(Function)报错 An error occurred while signing in: invalid_request - AADSTS65002
An error occurred while signing in: invalid_request - AADSTS65002: Consent between first party application 'c27c220f-ce2f-4904-927d-333864217eeb' and first party resource '797f4846-ba00-4fd7-ba43-dac1f8f63013' must be configured via preauthorization - applications owned and operated by Microsoft mus
313 13
|
6月前
|
存储 安全 Linux
【Azure App Service】在App Service中查看CA证书
在 Azure App Service 中,使用自签名或私有 CA 证书的远程服务可能会导致 SSL 握手失败。解决方法包括使用受信任 CA 签发的证书,或通过 App Service Environment 加载自定义根证书,实现安全连接。
155 3
|
4月前
|
Java 应用服务中间件 API
【App Service】部署War包到Azure云上遇404错误
Java应用部署至Azure App Service for Windows后报404,本地运行正常。经排查,日志提示类文件版本不兼容:应用由Java 17(class file version 61.0)编译,但环境仅支持到Java 11(55.0)。错误根源为Java版本不匹配。调整App Service的Java版本至17后问题解决,成功访问接口。
223 1
|
4月前
|
存储 Linux 网络安全
【Azure App Service】Root CA on App Service
Azure App Service for Windows应用连接外部SSL服务时,需确保其证书由受信任的根CA颁发。多租户环境下无法修改根证书,但ASE(单租户)可加载自定义CA证书。若遇证书信任问题,可更换为公共CA证书或将应用部署于ASE并导入私有CA证书。通过Kudu的PowerShell(Windows)或SSH(Linux)可查看当前受信任的根证书列表。
126 13
|
5月前
|
API 网络架构 容器
【Azure Container App】查看当前 Container App Environment 中的 CPU 使用情况的API
在扩展 Azure Container Apps 副本时,因 Container App Environment 的 CPU 核心数已达上限(500 cores),导致扩展失败。本文介绍如何使用 `az rest` 命令调用 Azure China Cloud 管理 API,查询当前环境的 CPU 使用情况,并提供具体操作步骤及示例。
183 16
|
5月前
|
数据安全/隐私保护
【Azure Function App】PowerShell Function 执行 Get-AzAccessToken 的返回值类型问题:System.String 与 System.Security.SecureString
将PowerShell Function部署到Azure Function App后,Get-AzAccessToken返回值类型在不同环境中有差异。正常为SecureString类型,但部分情况下为System.String类型,导致后续处理出错。解决方法是在profile.ps1中设置环境变量$env:AZUREPS_OUTPUT_PLAINTEXT_AZACCESSTOKEN=false,以禁用明文输出。
167 1
|
5月前
|
网络协议 Java Linux
【App Service】在Azure环境中如何查看App Service实例当前的网络连接情况呢?
在 Azure App Service(Windows 和 Linux)中部署应用时,分析网络连接状态是排查异常、验证端口监听及确认后端连接的关键。本文介绍如何在 Linux 环境中使用 `netstat` 命令查看特定端口(如 443、3306、6380)的连接情况,并解析输出结果。同时说明在 Windows App Service 中 `netstat` 被禁用的情况下,如何通过门户抓包等替代方法进行网络诊断。内容涵盖命令示例、操作步骤及附录说明,帮助开发者快速掌握云环境中的网络分析技巧。
156 11
|
6月前
|
JSON 数据格式
【Azure 环境】当一个Azure Function资源创建很久了,是否可以获取到它的创建时间呢?
用户在尝试获取 Azure Function App 的创建时间时发现,资源 JSON 中缺少 `createdTime` 字段,仅能查看到 `lastModifiedTime`。同时,活动日志和 Azure Resource Graph 查询也未能提供创建时间信息。经解答,Azure 并未为所有资源类型记录创建时间,建议在部署时将创建时间作为标签记录。若创建时间在 90 天内,可通过部署日志间接获取。
233 7
|
7月前
|
Java Shell Maven
【Azure Container App】构建Java应用镜像时候遇无法编译错误:ERROR [build 10/10] RUN ./mvnw.cmd dependency:go-offline -B -Dproduction package
在部署Java应用到Azure Container App时,构建镜像过程中出现错误:“./mvnw.cmd: No such file or directory”。尽管项目根目录包含mvnw和mvnw.cmd文件,但依然报错。问题出现在Dockerfile构建阶段执行`./mvnw dependency:go-offline`命令时,系统提示找不到可执行文件。经过排查,确认是mvnw文件内容异常所致。最终通过重新生成mvnw文件解决该问题,镜像成功构建。
292 1

热门文章

最新文章