简体   繁体   English

无法通过 arm 模板部署 azure function 应用程序

[英]unable to deploy azure function app through the arm template

Hi I have created azure funnction app with .net core.嗨,我已经创建了 azure 功能应用程序与 .net 核心。 I created everything through management portal.我通过管理门户创建了所有内容。 Its working fine.它工作正常。 I am trying to write arm templates for the resource creations.我正在尝试为资源创建编写 arm 模板。 So I exported arm template from portal and through azure devops I am running it to create resources.因此,我从门户导出 arm 模板,并通过 azure devops 运行它来创建资源。 I have selected increment changes.我选择了增量更改。 Below is my sample template.下面是我的示例模板。

{
            "type": "Microsoft.Web/sites",
            "apiVersion": "2018-11-01",
            "name": "[variables('fetchSciHubProductURLName')]",
            "location": "[parameters('location')]",
            "tags": {
                "BU": "[parameters('Division')]",
                "Environment": "[parameters('environment')]"
            },
            "kind": "functionapp,linux",
            "properties": {
                "serverFarmId": "[parameters('serverfarms_APSERDEVDVLGENSEAWE01_Linux_externalid')]",
                "clientAffinityEnabled": false,
                "httpsOnly": false,
                "siteConfig": {
                  "reservedInstanceCount": "0",
                  "appSettings": [
                    {
                      "name": "AzureWebJobsStorage",
                      "value": "secrete"
                    },
                    {
                      "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                      "value": "[parameters('storageAccount01APPINSIGHTS_INSTRUMENTATIONKEY')]"
                    },
                    {
                      "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
                      "value": "[parameters('storageAccount01APPLICATIONINSIGHTS_CONNECTION_STRING')]"
                    },
                    {
                      "name": "FUNCTIONS_EXTENSION_VERSION",
                      "value": "~3"
                    },
                    {
                      "name": "FUNCTIONS_WORKER_RUNTIME",
                      "value": "dotnet"
                    },
                    {
                      "name": "WEBSITE_ENABLE_SYNC_UPDATE_SITE",
                      "value": "true"
                    },
                    {
                      "name": "WEBSITE_RUN_FROM_PACKAGE",
                      "value": "1"
                    },
                    {
                      "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
                      "value": "true"
                    },
                    {
                      "name": "test1",
                      "value": "true"
                    }
                  ]
                }
            }
        },
        {
            "type": "Microsoft.Web/sites/functions",
            "apiVersion": "2018-11-01",
            "name": "[concat(variables('fetchSciHubProductURLName'), '/getproductsfromcoordinates')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', variables('fetchSciHubProductURLName'))]"
            ],
            "properties": {
                "script_root_path_href": "https://testqwe123.azurewebsites.net/admin/vfs/home/site/wwwroot/getproductsfromcoordinates/",
                "script_href": "https://testqwe123.azurewebsites.net/admin/vfs/home/site/wwwroot/bin/DemoThirdPartyDataDownload.AzFunction.dll",
                "config_href": "https://testqwe123.azurewebsites.net/admin/vfs/home/site/wwwroot/getproductsfromcoordinates/function.json",
                "href": "https://testqwe123.azurewebsites.net/admin/functions/getproductsfromcoordinates",
                "config": {}
            }
        },
        {
            "type": "Microsoft.Web/sites/functions",
            "apiVersion": "2018-11-01",
            "name": "[concat(variables('fetchSciHubProductURLName'), '/UploadFilesToAzureStorage')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', variables('fetchSciHubProductURLName'))]"
            ],
            "properties": {
                "script_root_path_href": "https://testqwe123.azurewebsites.net/admin/vfs/home/site/wwwroot/UploadFilesToAzureStorage/",
                "script_href": "https://testqwe123.azurewebsites.net/admin/vfs/home/site/wwwroot/bin/DemoThirdPartyDataDownload.AzFunction.dll",
                "config_href": "https://testqwe123.azurewebsites.net/admin/vfs/home/site/wwwroot/UploadFilesToAzureStorage/function.json",
                "href": "https://testqwe123.azurewebsites.net/admin/functions/UploadFilesToAzureStorage",
                "config": {}
            }
        }

I have problem with below types, Microsoft.Web/sites/functions When I check in this code, both Microsoft.Web/sites/functions fails.我对以下类型有问题,Microsoft.Web/sites/functions 当我签入此代码时,Microsoft.Web/sites/functions 都失败了。 It throws me below error.它使我陷入错误。

{
    "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
}

spent couple of hours to figure it out and still not finding it.花了几个小时才弄清楚,但仍然没有找到。 Can someone help me what I am doing wrong here?有人可以帮我在这里做错什么吗? Any help would be really helpful Thanks任何帮助都会非常有帮助谢谢

Working with ARM templates is oftentimes infuriating.使用 ARM 模板常常令人恼火。 For debugging, I recommend the following strategy.对于调试,我推荐以下策略。 To get things working, skip deploying through any kind of devops pipeline.为了让事情顺利进行,请跳过通过任何类型的 devops 管道进行部署。 Instead, deploy straight through Visual Studio through an ARM project.相反,通过 ARM 项目直接通过 Visual Studio 进行部署。

Next, strip the template down to a single resource, and get that resource working.接下来,将模板剥离为单个资源,并使该资源正常工作。 This may involve stripping the resource template itself down to its bare minimum to get it working, then add attributes back one by one until you figure out what is breaking.这可能涉及将资源模板本身剥离到最低限度以使其正常工作,然后一一添加属性,直到您弄清楚什么是破坏。

In your example above, I'd start with the "fetchSciHubProductURLName" resource.在上面的示例中,我将从“fetchSciHubProductURLName”资源开始。

Deploying from Visual Studio has the advantage of validating the template before deployment, and you may get better error messages that way.从 Visual Studio 部署的优点是在部署之前验证模板,这样您可能会收到更好的错误消息。

Also as a handy resource, the ARM template schema is published here .此外,作为方便的资源,ARM 模板架构在此处发布 There's also schemas for other ARM resources as well.还有其他 ARM 资源的架构。

It's not actually clear in the documentation but bindings are required and the error is rubbish as gives no hint as to what the issue is, just 'Internal Server Error'....文档中实际上并不清楚,但需要绑定,并且错误是垃圾,因为没有提示问题是什么,只是“内部服务器错误”......

Example: Function Quick Start Template示例: Function 快速入门模板

Required Example (Bicep):-所需示例(二头肌):-

config: {
      bindings: [
        {
          name: 'req'
          type: 'httpTrigger'
          direction: 'in'
          authLevel: 'function'
          methods: [
            'get'
          ]
        }
      ]
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 pipeline.yml 文件部署 azure 函数应用 - Unable to deploy azure function app using pipeline.yml file 没有模板链接的Azure ARM模板部署 - Azure ARM Template Deployment Without Template Linking 无法部署面向 .net 框架 4.8 的 azure 功能 - Unable to deploy azure function targeting .net framework 4.8 如何使用Azure SDK将Web应用程序部署到Azure - how to deploy web app to azure with azure sdk 部署后Az​​ure功能无法正常工作 - Azure Function not working after deploy Azure 函数模板 - Azure function template Is it possible to deploy multiple azure functions from different projects can be deployed in single Azure function app via Azure Devops pipeline? - Is it possible to deploy multiple azure functions from different projects can be deployed in single Azure function app via Azure Devops pipeline? 如何将基本HTML文件部署到Azure Bot函数应用程序的根目录? - How do you deploy a basic HTML file to the root directory of an Azure Bot function app? Azure函数“无法找到程序集” - Azure Function “Unable to find assembly” 无法在 azure 功能控制台(应用服务编辑器)中安装 npm keepagentalive 和 npm 版本 7 - unable to install npm keepagentalive and npm version 7 in azure function console (app service editor)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM