Problem
I’m utilizing bicep templates to deploy Azure Functions. I want to have an additional AppKey named management that is randomly created to connect the FunctionApp to my API-Management. Currently my solution for this looks like that
resource functionKeys 'Microsoft.Web/sites/host/functionKeys@2021-02-01' = {
name: '${functionApp.name}/default/management'
dependsOn: [
functionAppConfig
]
properties: {
name: 'management'
}
}
This worked for a few weeks, however now when I deploy the template in my DevOps Pipeline, I constantly receive the following arbitrary error.
ERROR: {"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"BadRequest","message":"{\r\n \"Code\": \"BadRequest\",\r\n \"Message\": \"Encountered an error (ServiceUnavailable) from host runtime.\",\r\n \"Target\": null,\r\n \"Details\": [\r\n {\r\n \"Message\": \"Encountered an error (ServiceUnavailable) from host runtime.\"\r\n },\r\n {\r\n \"Code\": \"BadRequest\"\r\n },\r\n {\r\n \"ErrorEntity\": {\r\n \"Code\": \"BadRequest\",\r\n \"Message\": \"Encountered an error (ServiceUnavailable) from host runtime.\"\r\n }\r\n }\r\n ],\r\n \"Innererror\": null\r\n}"}]}}
My API-Management is available and is successfully used by other FunctionApps, including the FunctionApp for which I am attempting to set this key. I get an error with little further information in the Azure Portal, stating that the failed resource is of type Microsoft.Web/sites/host/functionKeys. This type of code is only seen in the above-mentioned code.
Is there a better method to specify AppKeys for a functionApp created with a Bicep template? I discovered Microsoft. Web/sites/functions/keys@2020-06-01, but that necessitates a Microsoft parent. I use type Microsoft for web/sites/functions. Web/sites for my symbolic name functionApp.
Asked by DrEichenbach
Post is based on https://stackoverflow.com/questions/70708076/bicep-template-functionapp-app-key-creation