Function App host keys not created on ARM deployment

Razeen Hendricks 56 Reputation points
2021-05-24T15:10:30.72+00:00

I created an ARM template a while ago that was working fine, but all of a sudden now I have no host keys listed even though the arm deployment logging shows as successful.

99192-image.png

I've tried to create a "default" / "_master" host key in Azure Portal, and despite saying it's successful, it auto-refreshes and still lists nothing.
In the activity log, a 404 error is listed for "List Web Apps Functions Host Keys" with the message "Encountered an error (InternalServerError) from host runtime."

If I create it via Azure Portal, then those keys did show in one attempt, but then were not created in a later attempt (see above image). The configuration app settings of the portal and arm deployments are identical to the function app (that did have the host keys), including the "AzureWebJobsStorage" app setting value.
It's using a general usage V2 storage account, and a S1 app service plan.

Here's the json I'm using:

    {  
      "type": "Microsoft.Web/Sites",  
      "apiVersion": "2020-06-01",  
      "name": "[parameters('function_app_csharp_name')]",  
      "location": "[variables('location')]",  
      "kind": "functionapp",  
      "identity": {  
        "type": "SystemAssigned"  
      },  
      "properties": {  
        "enabled": true,  
        "httpsOnly": true,  
        "serverFarmId": "[concat(subscription().id, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', parameters('app_service_plan_name'))]",  
        "siteConfig": {  
          "alwaysOn": true,  
          "http20Enabled": true,  
          "minTlsVersion": "1.2",  
          "ftpsState": "Disabled",  
          "appSettings": [  
            {  
              "name": "AzureWebJobsStorage",  
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storage_account_name'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(concat(subscription().id, '/resourceGroups/', parameters('storage_accounts_resource_group'), '/providers/Microsoft.Storage/storageAccounts/', parameters('storage_account_name')), '2019-06-01').keys[0].value)]"  
            },  
            {  
              "name": "FUNCTIONS_EXTENSION_VERSION",  
              "value": "~3"  
            },  
            {  
              "name": "APPINSIGHTS_INSTRUMENTATIONKEY",  
              "value": "[reference(resourceId('Microsoft.Insights/Components', parameters('app_insights_name')), '2020-02-02-preview').InstrumentationKey]"  
            },  
            {  
              "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",  
              "value": "[reference(resourceId('Microsoft.Insights/Components', parameters('app_insights_name')), '2020-02-02-preview').ConnectionString]"  
            },  
            {  
              "name": "FUNCTIONS_WORKER_RUNTIME",  
              "value": "dotnet"  
            },  
            {  
              "name": "KEY_VAULT_NAME",  
              "value": "[parameters('keyvault_name')]"  
            }  
          ]  
        }  
      }  
    }  

Could you please assist in resolving this, and explain why this happens?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,017 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JayaC-MSFT 5,511 Reputation points
    2021-05-24T19:34:06.603+00:00

    Hello @Razeen Hendricks , Did you try restarting the function? Also you may refer to https://www.michaelscollier.com/inconsistent-functions-host-key for the script structure.

    Also, check if the storage account has any VNet configuration. If yes, then, you need to configure VNet for the function app too.

    https://stackoverflow.com/questions/63680651/arm-template-deployed-function-app-has-no-host-keys-and-throws-errors

    https://learn.microsoft.com/en-us/answers/questions/196946/azure-function-host-keys-missing.html

    Also, confirm if you have WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE , in case of consumption/ Premium