gpt4 book ai didi

.net - 无法通过arm模板部署azure功能应用程序

转载 作者:行者123 更新时间:2023-12-02 23:25:48 26 4
gpt4 key购买 nike

您好,我已经使用 .net core 创建了 azure function 应用程序。我通过管理门户创建了一切。它工作正常。我正在尝试为资源创建编写arm模板。因此,我从门户导出了arm模板,并通过azure devops运行它来创建资源。我选择了增量更改。下面是我的示例模板。

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

我对以下类型有问题,Microsoft.Web/sites/functions当我 checkin 此代码时,Microsoft.Web/sites/functions 都失败。它向我抛出以下错误。

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

花了几个小时才弄清楚,但还是没有找到。有人可以帮助我我在这里做错了什么吗?任何帮助都会非常有帮助谢谢

最佳答案

使用 ARM 模板常常令人恼火。对于调试,我推荐以下策略。为了让事情正常运行,请跳过通过任何类型的 DevOps 管道进行部署。相反,通过 ARM 项目直接通过 Visual Studio 进行部署。

接下来,将模板剥离为单个资源,并使该资源正常工作。这可能涉及将资源模板本身剥离到最低限度以使其正常工作,然后将属性一一添加回去,直到找出问题所在。

在上面的示例中,我将从“fetchSciHubProductURLName”资源开始。

从 Visual Studio 进行部署的优点是在部署之前验证模板,这样您可能会收到更好的错误消息。

另外,作为一个方便的资源,ARM 模板架构为 published here 。还有其他 ARM 资源的架构。

关于.net - 无法通过arm模板部署azure功能应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62936534/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com