title: How to specify partition key when using Azure Functions EventHub output binding?
body: <p>When using the <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs-output?tabs=in-process%2Cfunctionsv2%2Cextensionv5&amp;pivots=programming-language-csharp" rel="nofollow noreferrer">Azure Event Hubs output binding for Azure Functions</a>, is it possible to specify a <a href="https://docs.microsoft.com/en-us/dotnet/api/azure.messaging.eventhubs.producer.sendeventoptions.partitionkey?view=azure-dotnet#azure-messaging-eventhubs-producer-sendeventoptions-partitionkey" rel="nofollow noreferrer">partition key</a>?</p>
  <p>I have code similar to the below, but I don't see any way to specify a partition key prior to send.</p>
  <p>Alternatively, is there any way I could use the Function parameters to bind an <a href="https://docs.microsoft.com/en-us/dotnet/api/azure.messaging.eventhubs.producer.eventhubproducerclient?view=azure-dotnet" rel="nofollow noreferrer">EventHubProducerClient</a>, with an identity-based connection? This would be useful as the client allows for multiple ways to specify a partitionId.</p>
  <p>I'm aware that it's possible to wire up dependency injection, and to use that to get the client, but I was curious if I could avoid that.</p>
  <pre class="lang-cs prettyprint-override"><code>[FunctionName(&quot;EventHubOutput&quot;)]
  [return: EventHub(&quot;outputEventHubMessage&quot;, Connection = &quot;EventHubConnectionAppSetting&quot;)]
  public static string Run([TimerTrigger(&quot;0 */5 * * * *&quot;)] TimerInfo myTimer, ILogger log)
  {
      log.LogInformation($&quot;C# Timer trigger function executed at: {DateTime.Now}&quot;);
      return $&quot;{DateTime.Now}&quot;;
  }
  </code></pre>