Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.3k stars 431 forks source link

AzureWebJobs keys and values documentation #3827

Open linde12 opened 4 days ago

linde12 commented 4 days ago

Version

4.0.5455

Description

UPDATE: See comment below, issue was with local.settings.json configuration and poor documentation. I would like to keep this ticket to instead improve the documentation.

I am under the suspicion that the system certificate store is being ignored when using @app.queue_trigger

I am trying to connect to Azurite locally, and it works fine with HTTP and the HTTP connection string, but when i switch to HTTPS and run func start it times out after a while and gives me the following error message:

[2024-09-18T07:59:59.384Z] An unhandled exception has occurred. Host is shutting down.
[2024-09-18T07:59:59.384Z] Azure.Core: An error occurred while sending the request. System.Net.Http: An error occurred while sending the request. System.Net.Http: The response ended prematurely.

I do not want to use HTTP because i want to use DefaultAzureCredential (which in my case will fetch credential through managed identity) for my QueueClient which only works over HTTPS. However, over HTTPS the queue_trigger does not work. Also, fun thing to note is that i have to point my REQUESTS_CA_BUNDLE env var to my CA bundle to even make QueueClient from azure-storage-queue work (since i assumed it used requests under the hood) which is an annoyance but at least not a show stopper.

Steps to reproduce

I provided a minimally reproducible example over here: https://github.com/linde12/azure-functions-https-trigger-bug

Instructions in README.md. In short, im able to publish messages using QueueClient but @app.queue_trigger is unable to subscribe and times out (most likely due to certificates), but works if i instead use HTTP.

linde12 commented 4 days ago

I believe my local.settings.json as the cause - even though i had set Queue__queueServiceUri to the correct value, my value for AzureWebJobsQueue was still UseDevelopmentStorage=true which by points to HTTP, not HTTPS.

However, i was still able to publish messages just fine since QueueClient doesnt care about this (it uses the account_url from the constructor arguments) but for some reason @app.queue_trigger uses this connection string instead of my Queue__queueServiceUri

This is very confusing and i still see this as a bug (albeit not to do with certificates) - the documentation on these fields are also very brief to say the least, and i ended up having to look through source code.

Maybe we can clarify the documentation on these parameters? E.g. what "UseDevelopmentStorage=true" does, what the various "AzureWebJobsXXX" do and when they are used etc.

Why do i still have to create a "Queue__queueServiceUri"/pass a connection param to queue_trigger if now "AzureWebJobsQueue" is being used anyway?