title: Output an IotHub endpoint with Azure Resource Manager template
body: <p>I am about to script the deployment of our Azure solution. For that reason I create an Azure IoTHub with a Resource Manager Template. This works very well. But the problem is, I need the 
  <strong>Event Hub-compatible endpoint</strong> string for further deployments. </p>
  
  <p>See: <a href="https://picload.org/image/rrdopcia/untitled.png" rel="noreferrer">https://picload.org/image/rrdopcia/untitled.png</a></p>
  
  <p>I think, the solution would be, to output it in the template, but I cant get it to work.</p>
  
  <p>The output-section of my <em>template.json</em> actually looks like this:</p>
  
  <pre><code>    "outputs": {
      "clusterProperties": {
          "value": "[reference(parameters('clusterName'))]",
          "type": "object"
      },
      "iotHubHostName": {
          "type": "string",
          "value": "[reference(variables('iotHubResourceId')).hostName]"
      },
      "iotHubConnectionString": {
          "type": "string",
          "value": "[concat('HostName=', reference(variables('iotHubResourceId')).hostName, ';SharedAccessKeyName=', variables('iotHubKeyName'), ';SharedAccessKey=', listkeys(variables('iotHubKeyResource'), variables('iotHubVersion')).primaryKey)]"
      }
     }
  </code></pre>
  
  <p>And here are the variables I used:</p>
  
  <pre><code>    "variables": {
      "iotHubVersion": "2016-02-03",
      "iotHubResourceId": "[resourceId('Microsoft.Devices/Iothubs', parameters('iothubname'))]",
      "iotHubKeyName": "iothubowner",
      "iotHubKeyResource": "[resourceId('Microsoft.Devices/Iothubs/Iothubkeys', parameters('iothubname'), variables('iotHubKeyName'))]",
  },
  </code></pre>