Search code examples
azureazure-rm-templateazure-qna-maker

ARM Template for QnAmaker to output subscription key


I'm working on creating an ARM template for a QnAMaker resource type in Azure. After creating a QnAMaker resource and exporting the template it creates a number of resources:

  1. "Microsoft.CognitiveServices/accounts" of kind "QnAMaker"
  2. "Microsoft.Search/searchServices"
  3. "Microsoft.Web/serverfarms"
  4. "Microsoft.Web/sites" including appsettings including "PrimaryEndpointKey": "[concat(parameters('appName'), '-PrimaryEndpointKey')]"

The ARM template has a hardcoded value in the "/sites" resource rather than picking it up from another resource.

In the outputs, there is a link to qna runtime:

"qnaRuntimeEndpoint": {
            "type": "String",
            "value": "[concat('https://',reference(resourceId('Microsoft.Web/sites', parameters('appName'))).hostNames[0])]"
        }

What should the output value be for retrieving a subscription key for the QnAMaker resource?


Solution

  • This uses cognitive services related functions. Looking at some other examples I arrived at...

    "outputs": {
      "qnaKey":{
        "type": "string",
        "value": "[listKeys(concat(resourceGroup().id,'/providers/','Microsoft.CognitiveServices/accounts/', parameters('name')),'2016-02-01-preview').key1]"
      }
    }
    

    Cognitive Services API docs for listKeys