question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ARM deployment fails when using WEBSITE_RUN_FROM_PACKAGE and listkey function

See original GitHub issue

I have an Azure ARM template that deploys two Azure Functions to an Azure App Service Premium Plan (EP1). The templates add the default host key of the first function to the app settings of the first function using the listkey function:

"FunctionOneKey": "[listkeys(concat(variables('functionOneppId'), '/host/default/'),'2016-08-01').functionKeys.default]"

If I deploy this template to a new resource group, it works the first time (at least most of the time). Every subsequent deployment fails with a Bad Request Error:

{
    "Code": "BadRequest",
    "Message": "Encountered an error (ServiceUnavailable) from host runtime.",
    "Target": null,
    "Details": [
        {
            "Message": "Encountered an error (ServiceUnavailable) from host runtime."
        },
        {
            "Code": "BadRequest"
        },
        {
            "ErrorEntity": {
                "Code": "BadRequest",
                "Message": "Encountered an error (ServiceUnavailable) from host runtime."
            }
        }
    ],
    "Innererror": null
}

The reason for the ServiceUnavailable error is probably because Kudu adds a web.config with a rewrite rule (because I use WEBSITE_RUN_FROM_PACKAGE but don’t have deployed the function).

Investigative information

Please provide the following:

  • Function App version: 3.0 / 2.0
  • Region: Tested with North Europe, Germany West Central

Repro steps

The templates is available here.

You can reproduce this issue by deploying this template at least two times:

New-AzResourceGroupDeployment -ResourceGroupName 'my-resource-group' -TemplateFile "c:\Path\to\azuredeploy.json" -name "azuredeploy-$(New-Guid)"

Expected behavior

I should be able to run the ARM deployment multiple times without an error.

Known workarounds

The deployment works if I disable WEBSITE_RUN_FROM_PACKAGE.

Related information

I posted a related question on StackOverflow.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:31 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
DK-Denniscommented, Mar 17, 2020

Same issue here, I cannot use listkeys, and I get the same error message, which really does not say anything meaning- or helpful.

My template is deploying an EventGrid Topic and some EventTopic Subscribers, I only reference the Function App to get the key, in order to use it for the Subscribers. The Function App, however is Run From package, since C# code is deployed to it in an earlier stage.

1reaction
balag0commented, Apr 24, 2020

@ alI am closing this thread since there are too many different issues being conflated and it is very difficult to see what needs to be investigated / what is failing.

Please open a new (separate) issue and feel free to @ me and I will follow up individually.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Function ARM Deployment with listkeys results in ...
The function code is deployed later using the AzureFunctionApp@1 Azure DevOps Task as a Zip package (that is why I set WEBSITE_RUN_FROM_PACKAGE ......
Read more >
Azure Function ARM Deployment with ... - appsloveworld.com
1- using WEBSITE_RUN_FROM_PACKAGE = 1 must be set before deploying the Zip File, meaning adding dependency between the ZipDeploy with deploying AppSettings. why ......
Read more >
Function App host keys not created on ARM deployment
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 ......
Read more >
How to Deploy your Azure Function Automatically with ARM ...
In this post, I will explain how to create an Azure resource manager (ARM) template to deploy any Azure Function and show how...
Read more >
Common errors deploying Azure Bicep and ARM templates
Recently, I deployed some Azure resources using ARM and Bicep templates for a few customers. This is a write up of some errors...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found