我尝试在ARM模板中复制以下Azure命令。它基于文档,工作良好。
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管道。
我需要改变什么?
{
"$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"
}
]
}
}
}
]
} - 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'发布于 2021-03-11 22:20:45
解决方案是向模板中添加附加的小参数"linuxFxVersion": "DOTNET-ISOLATED|5.0"。我过去只在通过Azure管道部署我的应用程序时才设置它,但是现在似乎没有它也会阻止您的部署。
工作臂模板:
{
"$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"
}
}
}
]
}https://stackoverflow.com/questions/66591407
复制相似问题