Hi @ChrisU ,
I cloned your code and it seems correct. I managed to debug it and deploy it.
First. the debugging locally problem could be 2 things:
1 - Firewall. the trigger function defaults to AMQP, so, it is trying to reach tpc ports 5671 and 5672. usually I fix this by creating a firewall rule but I see couple months ago Microsoft has finally provided the option to change it to amqpwebsocket. First try adjusting the firewall. if doesn't work, try to change your host.json to this:
{
"version": "2.0",
"extensions": {
"eventHubs": {
"transportType" : "amqpWebSockets"
}
},
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
}
2 - Did your VS Code generated the python environment? if so, you should have a folder called ".venv"
Regarding deployment, did you use the vs code deploy?
I think part of it is an add-on bug. you can try to deploy without an ide: https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push if you prefer, but back to vs code, for now, after deployment, just make sure the azure function settings (in the cloud) match the ones on the app.seetings.json. the hub connection string must be the same name in Azure. did you grab that here?:
The storage is not mapped in the bindings but seems to be picked as long the name is "AzureWebJobsStorage". just need to make sure the value is correct.
Before moving into testing (and after deploying) remember you need to stop the azure function in azure when testing locally, otherwise the cloud will always grab the messages.
To send messages for testing, I use the iot hub add-on for vs code:
https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools
https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit
Did you add any devices? the vs code message sending add-on will expect at least one device. If you don't, just add on under the iot hub in azure before using the add-on
The right place to check if that is running in azure is here:
Functions > [the function you want to check] > Monitor:
----------
----------
the logs are good for initial troubleshoot. this line writes to that log:
logging.info('Python EventHub trigger processed an event: %s',
event.get_body().decode('utf-8'))
to debug locally, make sure the azure function is stopped. hit f5 or click here :
Remember to install this if you want to use the iot hub add-on: https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools . It helps testing/debugging
The confusion in VS Code is where to go to use add-ons. if you were in the devug section, to find the "send message" you need to click in the explorer:
you should see this:
If everything is good, you should see this:
Would be good to first debug locally to confirm you have the correct connection strings.
Let me know if that helps.