title: Azure Function App does not trigger by Event Hub
body: <p>Hey Guys.</p>
  <p>I have written Python function to handle JSON events that are coming to EventHub. Those events are generated by Debezium, and this part is working fine. My python code is also working fine when executed locally from Visual Studio Code. Problem starts when I deploy (using VSC) to Azure Function App. Seems like incoming events does not trigger function app execution.</p>
  <p>What am I doing wrong?</p>
  <p>My function code:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import List
  import logging
  import json
  import psycopg2
  
  import azure.functions as func
  
  
  def main(events: List[func.EventHubEvent]):
      #logging.info('Starting')
      conn = psycopg2.connect(database=&quot;RDSA&quot;, user='postgres', password='********', host='********.postgres.database.azure.com', port= '5432')
      #Creating a cursor object using the cursor() method
      cursor = conn.cursor()
  
      for event in events:
          row = json.loads(event.get_body().decode('utf-8'))
          #logging.info('Python EventHub trigger processed an event: %s',
          #                event.get_body().decode('utf-8'))
          rowDepartmentId=row[&quot;payload&quot;][&quot;after&quot;][&quot;departmentid&quot;]
          rowDepartmentName=row[&quot;payload&quot;][&quot;after&quot;][&quot;name&quot;]
          rowDepartmentGroupName=row[&quot;payload&quot;][&quot;after&quot;][&quot;groupname&quot;]
          rowModifiedDate=row[&quot;payload&quot;][&quot;after&quot;][&quot;modifieddate&quot;]
  
          SQL=&quot;&quot;&quot;INSERT INTO CDCSTAGE.TF_DEPARTMENT (departmentid, \&quot;name\&quot;, groupname, modifieddate)
               VALUES (%s, '%s', '%s', to_timestamp(%s / 1000000));&quot;&quot;&quot; % (rowDepartmentId, rowDepartmentName, rowDepartmentGroupName, rowModifiedDate)
  
          logging.info('=========== New record in DB: =============')
          logging.info('Department name: %s', row[&quot;payload&quot;][&quot;after&quot;][&quot;name&quot;])
          logging.info('Department group: %s', row[&quot;payload&quot;][&quot;after&quot;][&quot;groupname&quot;])
          logging.info('Modified date: %s', row[&quot;payload&quot;][&quot;after&quot;][&quot;modifieddate&quot;])
          logging.info('SQL generated: %s', SQL)
          logging.info('===========================================')
              #Executing an MYSQL function using the execute() method
          cursor.execute(SQL)
  
      #Closing the connection
      conn.commit() 
      cursor.close()
      conn.close()
  </code></pre>
  <p>function.json</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;scriptFile&quot;: &quot;__init__.py&quot;,
    &quot;bindings&quot;: [
      {
        &quot;type&quot;: &quot;eventHubTrigger&quot;,
        &quot;name&quot;: &quot;events&quot;,
        &quot;direction&quot;: &quot;in&quot;,
        &quot;eventHubName&quot;: &quot;adventureworks.humanresources.department&quot;,
        &quot;connection&quot;: &quot;AazureEventhubKafka_RootManageSharedAccessKey_EVENTHUB&quot;,
        &quot;cardinality&quot;: &quot;many&quot;,
        &quot;consumerGroup&quot;: &quot;$Default&quot;,
        &quot;dataType&quot;: &quot;binary&quot;
      }
    ]
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/SHYBi.png" rel="nofollow noreferrer">Trigger enabled on Azure portal</a></p>