【Azure Function App】解决Function App For Container 遇见ServiceUnavailable的异常

简介: 【Azure Function App】解决Function App For Container 遇见ServiceUnavailable的异常

问题描述

在使用Terraform创建Function App 后,部署函数时候遇见 ServiceUnavailable (Bad Request -- Encountered an error (ServiceUnavailable) from host runtime.) 问题。

查看Function App的高级工具(Kudu)站点和默认站点,均出现 Application Error页面。

 

问题解答

查看Function App的Azure管理页面,有提示错误消息“ Configure Container Settings “  , 但是点击后,却没有任何反应, 无法查看具体的消息.

然后查看Function App的部署中心页面, 也是没有任何信息输出,页面空白。

根据此处判断,UI上一定有JS错误,所以启用浏览器开发者模式(F12),查看Console中的错误信息。发现报错:Incorrect fxVersion set in the site config: DOCKER。

判断出,是Function App for Container关于DOCKER的配置错误,所以对比一个正确的Function App Container发现关键信息为:

因为对LinuxFxVersion的配置只说明了DOCKER,没有指定正确的Image 路径,所以Function App 无法加载部署中心,同时也无法正确的运行DOCKER指令和Kudu站点。

 

解决办法

通过az functionapp config set 指令,修改 --linux-fx-version的值,如:

az functionapp config set 
 --name <FUNCTION_APP>
 --resource-group <RESOURCE_GROUP>
 --linux-fx-version --% "DOCKER|mcr.microsoft.com/azure-functions/dotnet:4-appservice-quickstart"

For Windows)注意:因为在Powershell中 ”|“是终止符,所以如果没有特殊说明,执行上面的语句会下面的错误:

'mcr.microsoft.com' is not recognized as an internal or external command, operable program or batch file.

所以,需要加上 停止分析 (--%) 标记来阻止 PowerShell 将输入解释为 PowerShell 命令:

或者是在Terraform中对linux-fx-version赋予完整的值。

  • linux_fx_version - (Optional) Linux App Framework and version for the AppService, e.g. DOCKER|(golang:latest).

 

修改后,Function App页面恢复正常。

 

 

参考资料

Pin to a specific version on Linux: https://learn.microsoft.com/en-us/azure/azure-functions/set-runtime-version?tabs=portal#manual-version-updates-on-linux

Terraform设置Function App Linux fx version:https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app#linux_fx_version

相关文章
|
7天前
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub的解决之法
An exception occurred while retrieving properties for Event Hub: logicapp. Error Message: 'ClientSecretCredential authentication failed: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Che
|
13天前
|
安全
【Azure App Service】App service无法使用的情况分析
App Service集成子网后,如果子网网段中的剩余IP地址非常少的情况下,会在App Service实例升级时( 先加入新实例,然后在移除老实例 )。新加入的实例不能被分配到正确的内网IP地址,无法成功的访问内网资源。 解决方法就是为App Service增加子网地址, 最少需要/26 子网网段地址。
|
22天前
|
C++
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub
|
22天前
【Azure Logic App】在逻辑应用中开启或关闭一个工作流是否会对其它工作流产生影响呢?
【Azure Logic App】在逻辑应用中开启或关闭一个工作流是否会对其它工作流产生影响呢?
|
22天前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
|
22天前
|
安全 JavaScript 应用服务中间件
【Azure Function App】如何修改Azure函数应用的默认页面呢?
【Azure Function App】如何修改Azure函数应用的默认页面呢?
|
22天前
|
C# C++ Python
【Azure 应用服务】Azure Durable Function(持久函数)在执行Activity Function时候,因为调用函数名称错误而导致长时间无响应问题
【Azure 应用服务】Azure Durable Function(持久函数)在执行Activity Function时候,因为调用函数名称错误而导致长时间无响应问题
|
22天前
|
SQL JavaScript 前端开发
【Azure 应用服务】Azure JS Function 异步方法中执行SQL查询后,Callback函数中日志无法输出问题
【Azure 应用服务】Azure JS Function 异步方法中执行SQL查询后,Callback函数中日志无法输出问题
|
22天前
|
JSON 数据格式 Python
【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?
【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?
|
22天前
|
C++ Python
【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误
【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误

热门文章

最新文章