title: QueueTrigger Bindings for Sendgrid -Python
body: <p>Guided by this <a href="https://github.com/yokawasa/azure-functions-python-samples/blob/master/v1functions/queue-trigger-sendgrid/function/function.json.example" rel="nofollow noreferrer">post</a> I have written the following queuetrigger code intended to send emails when a message is queued.</p>
  <pre><code>import logging
  import sendgrid
  import azure.functions as func
  import os
  def main(msg: func.QueueMessage) -&gt; None:
      logging.info('Python queue trigger function processed a queue item: %s',
                   msg.get_body().decode('utf-8'))
      
     
      data = {
          &quot;personalizations&quot;: [
            {
              &quot;to&quot;: [
                {
                  &quot;email&quot;: &quot;rrrrrrrr&quot;
                }
              ],
              &quot;subject&quot;: &quot;Sending with SendGrid is Fun&quot;
            }
          ],
          &quot;from&quot;: {
            &quot;email&quot;: &quot;ghyu&quot;
          },
          &quot;content&quot;: [
            {
              &quot;type&quot;: &quot;text/plain&quot;,
              &quot;value&quot;: &quot;and easy to do anywhere, even with Python&quot;
            }
           ]
      }
      print('Sending email using SendGrid:', data)
      with open(os.environ[_AZURE_FUNCTION_SENDGRID_OUTPUT_ENV_NAME], 'wb') as f:
        json.dump(data,f)
  </code></pre>
  <p><strong>function.json</strong></p>
  <pre><code>{
    &quot;scriptFile&quot;: &quot;__init__.py&quot;,
    &quot;bindings&quot;: [
      {
        &quot;name&quot;: &quot;msg&quot;,
        &quot;type&quot;: &quot;queueTrigger&quot;,
        &quot;direction&quot;: &quot;in&quot;,
        &quot;queueName&quot;: &quot;outqueue1&quot;,
        &quot;connection&quot;: &quot;storageaccountautom92bb_STORAGE&quot;
      },
      
      {
        
        &quot;name&quot;: &quot;outputMessage&quot;,
        &quot;type&quot;: &quot;sendGrid&quot;,
        &quot;from&quot;: &quot;ghyu&quot;,
        &quot;apiKey&quot;: &quot;MY_SENDGRID_API_KEY&quot;,
        &quot;direction&quot;: &quot;out&quot;
      }
    ],
    &quot;disabled&quot;: false
  }
  </code></pre>
  <p><strong>local.settings.json</strong></p>
  <pre><code>{
    &quot;IsEncrypted&quot;: false,
    &quot;Values&quot;: {
      &quot;AzureWebJobsStorage&quot;: &quot;hjk&quot;,
      &quot;FUNCTIONS_WORKER_RUNTIME&quot;: &quot;python&quot;,
      &quot;storageaccountautom92bb_STORAGE&quot;: &quot;hjk&quot;,
      &quot;MY_SENDGRID_API_KEY&quot;: &quot;tyhuE&quot;,
      &quot;_AZURE_FUNCTION_SENDGRID_OUTPUT_ENV_NAME&quot; : &quot;GIS klop&quot;,
      &quot;_AZURE_FUNCTION_QUEUE_INPUT_ENV_NAME&quot; : &quot;msg&quot;
    }
  }
  </code></pre>
  <p>Whereas the function responds to messages as they queue, it is not able to send emails. It throws an error;</p>
  <pre><code>the following parameters are declared in function.json but not in Python: {'outputMessage'}
  </code></pre>
  <ol>
  <li>How best can I resolve this?</li>
  <li>Are the outward bindings correct?</li>
  </ol>