title: ARM Template - Get specific host key of a function
body: <p>I have to create a host key (use in API Management backend) for my Azure function with a name passed in via a parameter.
  I can't find out how I can use the the listKeys to fetch one particular host key by it's name.</p>
  <p>I'm creating the host key like this, if I do not add my output this is working properly</p>
  <pre><code>{
                              &quot;type&quot;: &quot;Microsoft.Web/sites/host/functionKeys&quot;,
                              &quot;apiVersion&quot;: &quot;2018-11-01&quot;,
                              &quot;name&quot;: &quot;[concat(variables('functionSite-name'), '/default/',variables('apim-name'))]&quot;,
                              &quot;properties&quot;: {
                                  &quot;name&quot;: &quot;[variables('apim-name')]&quot;
                              }
                          }
  </code></pre>
  <p>I tried this, got it from another post but it returns the error :
  {&quot;code&quot;:&quot;DeploymentFailed&quot;,&quot;message&quot;:&quot;At least one resource deployment operation failed. Please list deployment operations for details. Please see <a href="https://aka.ms/DeployOperations" rel="nofollow noreferrer">https://aka.ms/DeployOperations</a> for usage details.&quot;,&quot;details&quot;:[{&quot;code&quot;:&quot;InvalidResourceNamespace&quot;,&quot;message&quot;:&quot;The resource namespace 'GetVersionPOCApiManagement' is invalid.&quot;}]}</p>
  <pre><code>[listkeys(concat(variables('functionSite-name'), '/host/default/'),'2016-08-01').functionKeys[variables('apim-name')]]
  </code></pre>
  <p>'functionSite-name' is the name of my Azure Function (Microsoft.Web/sites)
  'apim-name' is the name of the created host key (Microsoft.Web/sites/host/functionKeys)</p>
  <p>As a reference my full script, I use a deployment because my Azure function is in another resource group and I need to create the host key and then add it to a key vault. After that I have to configure the API Management instance to use this Azure Function.</p>
  <pre><code>{
      &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,
      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
      &quot;parameters&quot;: {
      },
      &quot;variables&quot;: {
          &quot;apim-name&quot;: &quot;eud-sse-poc-apim&quot;,
          &quot;api-name&quot;: &quot;GetVersionPOCApiManagement&quot;,
          &quot;functionSite-name&quot;: &quot;GetVersionPOCApiManagement&quot;,
          &quot;functionSite-ResourceGroup&quot;: &quot;eud-sse-poc-datafactory-rg&quot;
      },
      &quot;resources&quot;: [
          {
              &quot;type&quot;: &quot;Microsoft.Resources/deployments&quot;,
              &quot;apiVersion&quot;: &quot;2020-10-01&quot;,
              &quot;name&quot;: &quot;azureFunctionDeployments&quot;,
              &quot;resourceGroup&quot;: &quot;[variables('functionSite-ResourceGroup')]&quot;,
              &quot;properties&quot;: {
                  &quot;mode&quot;: &quot;Incremental&quot;,
                  &quot;template&quot;: {
                      &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,
                      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
                      &quot;resources&quot;: [
                          {
                              &quot;type&quot;: &quot;Microsoft.Web/sites/host/functionKeys&quot;,
                              &quot;apiVersion&quot;: &quot;2018-11-01&quot;,
                              &quot;name&quot;: &quot;[concat(variables('functionSite-name'), '/default/',variables('apim-name'))]&quot;,
                              &quot;properties&quot;: {
                                  &quot;name&quot;: &quot;[variables('apim-name')]&quot;
                              }
                          }
                      ],
                      &quot;outputs&quot;: {
                          &quot;hostKey&quot;: {                            
                              &quot;type&quot;: &quot;string&quot;,
                              &quot;value&quot;: &quot;[listkeys(concat(variables('functionSite-name'), '/host/default/'),'2016-08-01').functionKeys[variables('apim-name')]]&quot;
                          }
                      }
                  }
              }
          }
  
  
  
      ],
      &quot;outputs&quot;: {}
  }
  </code></pre>
  <p>Any suggestions?</p>