diff --git a/azure_functions_worker/dispatcher.py b/azure_functions_worker/dispatcher.py index 902e9d86e..807985cc6 100644 --- a/azure_functions_worker/dispatcher.py +++ b/azure_functions_worker/dispatcher.py @@ -525,6 +525,7 @@ async def _handle__invocation_request(self, request): invoc_request = request.invocation_request invocation_id = invoc_request.invocation_id function_id = invoc_request.function_id + http_v2_enabled = False # Set the current `invocation_id` to the current task so # that our logging handler can find it. @@ -555,6 +556,10 @@ async def _handle__invocation_request(self, request): args = {} + http_v2_enabled = self._functions.get_function(function_id) \ + .is_http_func and \ + HttpV2Registry.http_v2_enabled() + for pb in invoc_request.input_data: pb_type_info = fi.input_types[pb.name] if bindings.is_trigger_binding(pb_type_info.binding_name): @@ -570,10 +575,6 @@ async def _handle__invocation_request(self, request): shmem_mgr=self._shmem_mgr, is_deferred_binding=pb_type_info.deferred_bindings_enabled) - http_v2_enabled = self._functions.get_function(function_id) \ - .is_http_func and \ - HttpV2Registry.http_v2_enabled() - if http_v2_enabled: http_request = await http_coordinator.get_http_request_async( invocation_id) diff --git a/tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py b/tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py index 4df62c480..5db75fd12 100644 --- a/tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py +++ b/tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py @@ -257,3 +257,13 @@ def put_blob_bytes(req: func.HttpRequest, file: func.Out[bytes]) -> str: def blob_cache(req: func.HttpRequest, client: blob.BlobClient) -> str: return client.download_blob(encoding='utf-8').readall() + + +@app.function_name(name="invalid_connection_info") +@app.blob_input(arg_name="client", + path="python-worker-tests/test-blobclient-triggered.txt", + connection="NotARealConnectionString") +@app.route(route="invalid_connection_info") +def invalid_connection_info(req: func.HttpRequest, + client: blob.BlobClient) -> str: + return client.download_blob(encoding='utf-8').readall() diff --git a/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py b/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py index 54e36f9f1..eaa1bc726 100644 --- a/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py +++ b/tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py @@ -179,3 +179,9 @@ def test_caching(self): r = self.webhost.request('GET', 'blob_cache') self.assertEqual(r.status_code, 200) + + def test_failed_client_creation(self): + r = self.webhost.request('GET', 'invalid_connection_info') + # Without the http_v2_enabled default definition, this request would time out. + # Instead, it fails immediately + self.assertEqual(r.status_code, 500)