Reputation: 18526
I try to replicate the following Azure CLI command in an ARM template. It is based on the documentation and works fine.
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
However, when executing the ARM template below, all I get after opening up https://<APP_NAME>.azurewebsites.net is Service unavailable
. If I use the AZ command, I see Your Functions 3.0 app is up and running
. Publishing my functions via func azure functionapp publish
or Azure Pipelines also seem to time out most of the time, especially Azure Pipelines using the Azure Function App task.
What do I need to change?
{
"$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'
Upvotes: 3
Views: 864
Reputation: 18526
The solution was to add the little extra parameter "linuxFxVersion": "DOTNET-ISOLATED|5.0"
to the template. I used to set this only when deploying my application via Azure Pipelines, but it seems not having this can also block your deployment at the moment.
Working ARM template:
{
"$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"
}
}
}
]
}
Upvotes: 10