检索Azure Functions函数应用程序键时遇到主机运行时错误(InternalServerError)

mgdq6dx1  于 2023-10-22  发布在  其他
关注(0)|答案(1)|浏览(107)

已经在互联网上搜索了一段时间,仍然没有在解决这个问题上取得多大成功。
通过ARM模板/Azure DevOps YAML管道部署Azure Function应用程序。部署成功完成,但是,任何检索功能应用程序键列表的尝试都会使网页处于持续加载状态。尝试使用Azure CLi检索密钥也会返回错误请求响应。在Azure门户中查看函数应用程序的活动日志时,会在列表函数主机键上显示失败状态。
完整错误消息:

{"Code":"BadRequest","Message":"Encountered an error (InternalServerError) from host runtime.","Target":null,"Details":[{"Message":"Encountered an error (InternalServerError) from host runtime."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","Message":"Encountered an error (InternalServerError) from host runtime."}}],"Innererror":null}

我有...

  • 已检查AzureWebJobs存储配置值是否正确
  • 使用新名称重新部署函数app,导致相同的错误
  • 重新部署存储帐户和功能应用程序,导致相同的错误
  • 删除存储帐户和功能应用程序,并在第二天重新部署,导致相同的错误
  • 检查有和没有函数代码的函数应用程序,结果相同
  • 已检查存储帐户设置,设置为公共访问,无vnet配置

除此之外,还部署了一些额外的功能应用程序,但所有其他应用程序都按预期运行。这个功能应用程序以前工作,有一天它停止.
功能扩展版本~4功能扩展
ARM模板:https://github.com/NZLorenzo04/azure-functionapp-template/blob/main/template.json
我认为这是一个孤立的问题,不知道是什么原因造成的,也不知道如何解决。期待伟大的思想堆栈溢出的支持,因为我在一个损失.

nc1teljy

nc1teljy1#

参考我的SO线程答案中的ARM模板,并通过Azure DevOps yaml管道部署Function应用程序。

我的Azure存储库:-

我的完整ARM模板:-您可以使用此ARM模板进行测试:-

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appName": {
            "defaultValue": "[concat('funtionapp-', uniqueString(resourceGroup().id))]",
            "type": "string",
            "metadata": {
                "description": "The name of the function app that you wish to create."
            }
        },
        "sku": {
            "defaultValue": "S1",
            "type": "string",
            "metadata": {
                "description": "The pricing tier for the hosting plan."
            }
        },
        "workerSize": {
            "defaultValue": "0",
            "allowedValues": [
                "0",
                "1",
                "2"
            ],
            "type": "String",
            "metadata": {
                "description": "The instance size of the hosting plan (small, medium, or large)."
            }
        },
        "storageAccountType": {
            "defaultValue": "Standard_LRS",
            "allowedValues": [
                "Standard_LRS",
                "Standard_GRS",
                "Standard_ZRS",
                "Premium_LRS"
            ],
            "type": "string",
            "metadata": {
                "description": "Storage Account type"
            }
        },
        "repoURL": {
            "defaultValue": "https://github.com/sid24desai/FunctionApp49",
            "type": "string",
            "metadata": {
                "description": "The URL for the GitHub repository that contains the project to deploy."
            }
        },
        "branch": {
            "defaultValue": "master",
            "type": "string",
            "metadata": {
                "description": "The branch of the GitHub repository to use."
            }
        },
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location for all resources."
            }
        }
    },
    "variables": {
        "functionAppName": "[parameters('appName')]",
        "hostingPlanName": "[concat(parameters('appName'), '-plan')]",
        "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'functions')]"
    },
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2021-02-01",
            "name": "[variables('storageAccountName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "[parameters('storageAccountType')]"
            },
            "kind": "Storage"
        },
        {
            "type": "Microsoft.Web/serverfarms",
            "apiVersion": "2020-12-01",
            "name": "[variables('hostingPlanName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "[parameters('sku')]"
            },
            "properties": {
                "workerSize": "[parameters('workerSize')]",
                "numberOfWorkers": 1
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2020-12-01",
            "name": "[variables('functionAppName')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
                "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
            ],
            "kind": "functionapp",
            "properties": {
                "name": "[variables('functionAppName')]",
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
                "clientAffinityEnabled": false,
                "siteConfig": {
                    "alwaysOn": true,
                    "cors": {
                        "allowedOrigins": [
                            "*"
                        ]
                    },
                    "appSettings": [
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~v4"
                        },
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]"
                        },
                        {
                            "name": "AzureWebJobsDashboard",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]"
                        }
                    ]
                }
            },
            "resources": [
                {
                    "type": "sourcecontrols",
                    "apiVersion": "2020-12-01",
                    "name": "web",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"
                    ],
                    "properties": {
                        "RepoUrl": "[parameters('repoURL')]",
                        "branch": "[parameters('branch')]",
                        "IsManualIntegration": true
                    }
                }
            ]
        }
    ]
}

输出:-

添加了CORS设置,以允许https://portal.azure.com从门户运行函数触发器:-

使用以下命令检索功能键:-

az functionapp keys list -g valleyrg103 -n funtionapp-pfau2zquvlcbw --query functionKeys.default

相关问题