首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过ARM模板创建.NET 5功能应用程序后的“服务不可用”

通过ARM模板创建.NET 5功能应用程序后的“服务不可用”
EN

Stack Overflow用户
提问于 2021-03-11 22:20:45
回答 1查看 768关注 0票数 3

我尝试在ARM模板中复制以下Azure命令。它基于文档,工作良好。

代码语言:javascript
复制
az functionapp create --resource-group AzureFunctionsQuickstart-rg --p myappserviceplan --runtime dotnet-isolated --runtime-version 5.0 --functions-version 3 --name <APP_NAME> --storage-account <STORAGE_NAME> --os-type linux

但是,在执行下面的ARM模板时,我打开https://.azurewebsites.net后得到的只有Service unavailable。如果我使用AZ命令,我会看到Your Functions 3.0 app is up and running。通过func azure functionapp publish或Azure管道发布我的函数似乎大部分时间都是超时的,特别是使用Azure函数应用程序任务的Azure管道。

我需要改变什么?

代码语言:javascript
复制
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": {
      "type": "string",
      "metadata": {
        "description": "The name of the function app that you wish to create."
      }
    },
    "storageAccountName": {
      "type": "string",
      "metadata": {
        "description": "The name of the existing storage account."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for app function"
      }
    },
    "hostingPlanName": {
      "type": "string",
      "metadata": {
        "description": "Name of the existing hosting plan to use."
      }
    }
  },
  "variables": {
    "functionAppName": "[parameters('appName')]"
  },
  "resources": [
    {
      "apiVersion": "2020-06-01",
      "type": "Microsoft.Web/sites",
      "name": "[variables('functionAppName')]",
      "location": "[parameters('location')]",
      "kind": "functionapp,linux",
      "dependsOn": [
      ],
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
        "siteConfig": {
          "alwaysOn": true,
          "appSettings": [
            {
              "name": "AzureWebJobsStorage",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
            },
            {
              "name": "FUNCTIONS_EXTENSION_VERSION",
              "value": "~3"
            },
            {
              "name": "FUNCTIONS_WORKER_RUNTIME",
              "value": "dotnet-isolated"
            }
          ]
        }
      }
    }
  ]
}
代码语言:javascript
复制
          - task: AzureFunctionApp@1
            displayName: 'Azure functions app deploy'
            inputs:
              azureSubscription: '$(azureSubscription)'
              appType: 'functionAppLinux'
              appName: '$(functionAppName)'
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              runtimeStack: 'DOTNET-ISOLATED|5.0'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-11 22:20:45

解决方案是向模板中添加附加的小参数"linuxFxVersion": "DOTNET-ISOLATED|5.0"。我过去只在通过Azure管道部署我的应用程序时才设置它,但是现在似乎没有它也会阻止您的部署。

工作臂模板:

代码语言:javascript
复制
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": {
      "type": "string",
      "metadata": {
        "description": "The name of the function app that you wish to create."
      }
    },
    "storageAccountName": {
      "type": "string",
      "metadata": {
        "description": "The name of the existing storage account."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for app function"
      }
    },
    "hostingPlanName": {
      "type": "string",
      "metadata": {
        "description": "Name of the existing hosting plan to use."
      }
    }
  },
  "variables": {
    "functionAppName": "[parameters('appName')]"
  },
  "resources": [
    {
      "apiVersion": "2020-06-01",
      "type": "Microsoft.Web/sites",
      "name": "[variables('functionAppName')]",
      "location": "[parameters('location')]",
      "kind": "functionapp,linux",
      "dependsOn": [
      ],
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
        "siteConfig": {
          "alwaysOn": true,
          "appSettings": [
            {
              "name": "AzureWebJobsStorage",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
            },
            {
              "name": "FUNCTIONS_EXTENSION_VERSION",
              "value": "~3"
            },
            {
              "name": "FUNCTIONS_WORKER_RUNTIME",
              "value": "dotnet-isolated"
            }
          ],
          "linuxFxVersion": "DOTNET-ISOLATED|5.0"
        }
      }
    }
  ]
}
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66591407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档