question

RazeenHendricks-7065 avatar image
0 Votes"
RazeenHendricks-7065 asked azure-cxp-api edited

Function App host keys not created on ARM deployment

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
image.png (28.6 KiB)
image.png (70.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JayaC-MSFT avatar image
0 Votes"
JayaC-MSFT answered JayaC-MSFT commented

Hello @RazeenHendricks-7065, 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://docs.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


· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JayaC-MSFT

I have restarted it a few times, there is no vnet config set up on the storage account (please note that I have indicated mixed results (success and failure in different attempts) when trying to create it via the Azure Portal).

Those WEBSITE* variables are not set (as you may see in the template code that I have provided in my post, and I've already indicated that an app service plan is in place.

I've already referenced all those links you've supplied before posting this.

What baffles me is that the AzureWebJobsStorage value is set with the AccountKey parameter which is retrieved by the listKeys function, which to me proves that the storage account is accessible. That key is the same value whether the host keys are generated or not.

What else may be a cause of this?

0 Votes 0 ·

Hi @JayaC-MSFT

After experimenting a bit more, I've discovered that when I use a different name for the function app when creating with the Azure Portal or ARM template, then the host keys do get generated successfully.

I then also tried using a different storage account, and that worked with the original function app name, creating the host keys.

I don't know the inner workings of this provisioning process, so could you please get an explanation on what's happening here? What configuration on the storage account could be preventing the host keys from being generated for the function app?

0 Votes 0 ·
JayaC-MSFT avatar image JayaC-MSFT RazeenHendricks-7065 ·

Hello @RazeenHendricks-7065, this happens mostly because of any restriction ( firewall/ network) on the storage side or any configuration related issue. If you have not deleted the problematic function app , I might need some additional data to check.
Also, between the new and old function app did you do anything differently regarding the configuration?

0 Votes 0 ·
Show more comments