Creating Function App Key via Biceps

Richard Schaffranek 1 Reputation point
2022-07-11T06:29:33.673+00:00

Dear All,

I am trying to create an azure app function key via the following lines from gitlab:

resource computeFunctionUser 'Microsoft.Web/sites/functions/keys@2022-03-01' = {
name: '${FUNCTION_NAME}/default/KEY_NAME'
properties: {
name: 'KEY_NAME'
}
}

All I get wen running the gitlab ci/cd pipline is this:

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}"}]}}

Some in the portal:

{"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":[{"message":"Encountered an error (ServiceUnavailable) from host runtime."}]}

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

2 answers

Sort by: Most helpful
  1. Bruno Lucas 4,421 Reputation points MVP
    2022-07-12T10:47:38.787+00:00

    Hi @Richard Schaffranek

    That doesn't seem to be the parameters for a function key:

    https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites/functions/keys?tabs=bicep

    Beside the name you need at least the "parent" since that is a function app key:

    219835-image.png

    Where did you get that "@2022-03-01" version? Look like the latest is "@2021-03-01" :

    219876-image.png

    0 comments No comments

  2. VinodKumar-0434 306 Reputation points
    2022-07-13T06:12:45.18+00:00

    Hi @Richard Schaffranek

    If you are using an existing function and creating the function key child resource outside of your parent resource template then you have to refer parent using parent key.

    Reference link

    1. child-resource-name-type
    2. function-key-bicep-template Here is the solution for your request. Please upvote if you find this useful. Thanks. resource functionapp 'Microsoft.Web/sites/functions@2022-03-01' existing = { name: 'biceppoc/HttpTrigger1' } resource functionappKey 'Microsoft.Web/sites/functions/keys@2022-03-01' = { name: 'managementkey' parent: functionapp properties :{ name : 'managementkey' }
      }

    And here is the screenshots for the result.

    220169-functionkey.png

    220281-functiondeployment.png