Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

[BUG] Az Function python library doesnt create eventhub function: `Object reference not set to an instance of an object.` #1351

Closed BillmanH closed 7 months ago

BillmanH commented 7 months ago

Investigative information

Please provide the following:

Repro steps

  1. func init az-functions
  2. func new --template "Azure Event Hub" --name myFunction

To verify that everything else is configured correctly:

  1. func new --template "Timer trigger" --name myFunction
  2. function creates successfully. No issue.

The func tools is able to create the HTTP function but not the EventHub function. Making it impossible to work with Azure EventHub Triggers.  

Expected behavior

Function is created.

Actual behavior

Object reference not set to an instance of an object. No function is created

Known workarounds

If you can find an example of the eventhub function, you can copy and paste it manually.

bhagyshricompany commented 7 months ago

Thanks for reporting .Will check and update.Thanks

hallvictoria commented 7 months ago

Hi @BillmanH, could you please provide a screenshot of your app code and the full error logs that show up? Thanks

pyrabbit commented 7 months ago

I am also seeing this issue with Durable Functions orchestrator. Verbose logging doesn't return any additional information outside of what was originally reported.

Func CLI Version: 4.0.5455

BillmanH commented 7 months ago

@hallvictoria , sure. Here you go: image

BillmanH commented 7 months ago

Not really any logs to call out.

@hallvictoria , This is the Azure Functions CLI tools. It's what you run to generate the starter code for your function. When working properly you can generate all of the files by executing the command line above. So, per your request, there is no "app code" because this is the command that would generate it. The issue wouldn't be with my application (which I haven't made yet). The issue is with the CLI core tools.

Cheers

BillmanH commented 7 months ago

I'm wondering if the core tools supports the event hub template. It says that it does.

Running the command: func templates list

Returns:

Python Templates:
  Azure Blob Storage trigger
  Azure Cosmos DB trigger
  Durable Functions activity
  Durable Functions entity
  Durable Functions HTTP starter
  Durable Functions orchestrator
  Azure Event Grid trigger
  **Azure Event Hub trigger**
  HTTP trigger
  Kafka output
  Kafka trigger
  Azure Queue Storage trigger
  RabbitMQ trigger
  Azure Service Bus Queue trigger
  Azure Service Bus Topic trigger
  SQL Input Binding
  SQL Output Binding
  Timer trigger

However, this could just be a static list somewhere, not a list of template folders. Object reference not set to an instance of an object could mean that it's looking for the EventHub template, but it doesn't exist in the tool. This would be bad. Hopefully MSFT can confirm. It could also mean that MSFT has removed support for the Python Event Hub Trigger, but didn't update this static list. I'm speculating here.

If so, that would explain why the timer trigger runs fine, but the EH trigger doesn't. The folder is missing in the CLI tools set.

@hallvictoria , can you confirm that this trigger is supported?

hallvictoria commented 7 months ago

Hi @BillmanH, yes, the Event Hub trigger is supported, and the template name is Azure Event Hub trigger. Please try running func new --template "Azure Event Hub trigger" --name myFunction and let me know if the same issue occurs.

Thanks

BillmanH commented 7 months ago

image

Same issue.

BillmanH commented 7 months ago

Just to help you out I'm reproing @pyrabbit 's issue as well. image

As you can see, there are more than one of the listed functions that do not work. I'm not going to go through them one by one, but you can see that some work and some don't.

By comparison, the HTTP function (the one used in the demo and tutorials) does work. image

hallvictoria commented 7 months ago

Thanks for your patience. One last thing -- does func new --template "EventHub trigger" --name myFunction work for you?

BillmanH commented 7 months ago

It did, image

Can you confirm for the Durable function as well? Is there some way to know the proper text string that generates the function? Or can you update the list so that a user can know what the expected text field will be? There may be other cases where the list in func templates list differs from the string expected by the --template argument.

hallvictoria commented 7 months ago

Templates for Durable functions aren't supported at this moment. I agree, the list provided from func templates list is outdated and confusing. We'll look into a fix that will make this clearer and easier to use.

hallvictoria commented 7 months ago

Linking relevant Core Tools issues Unsupported templates: Azure/azure-functions-core-tools#3529 Inconsistent naming: Azure/azure-functions-python-worker#1427

BillmanH commented 7 months ago

As there are other issues opened, I can close this one. Thanks @hallvictoria for the fix and the workaround. I'm unblocked.