Skip to content

Commit 6427215

Browse files
authored
bug: Backport 4.27: Update function directory in load request to use /home/site/wwwroot (#1481)
* bug: Backport to 4.27 * Linting fix
1 parent 6a50c07 commit 6427215

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

azure_functions_worker/dispatcher.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,11 @@ def load_function_metadata(self, function_app_directory, caller_info):
344344
function_path = os.path.join(function_app_directory,
345345
script_file_name)
346346

347+
# For V1, the function path will not exist and
348+
# return None.
347349
self._function_metadata_result = (
348-
self.index_functions(function_path)) \
350+
self.index_functions(function_path,
351+
function_app_directory)) \
349352
if os.path.exists(function_path) else None
350353

351354
async def _handle__functions_metadata_request(self, request):
@@ -400,8 +403,9 @@ async def _handle__function_load_request(self, request):
400403

401404
logger.info(
402405
'Received WorkerLoadRequest, request ID %s, function_id: %s,'
403-
'function_name: %s',
404-
self.request_id, function_id, function_name)
406+
'function_name: %s, function_app_directory : %s',
407+
self.request_id, function_id, function_name,
408+
function_app_directory)
405409

406410
programming_model = "V2"
407411
try:
@@ -672,15 +676,16 @@ async def _handle__function_environment_reload_request(self, request):
672676
request_id=self.request_id,
673677
function_environment_reload_response=failure_response)
674678

675-
def index_functions(self, function_path: str):
679+
def index_functions(self, function_path: str, function_dir: str):
676680
indexed_functions = loader.index_function_app(function_path)
677681
logger.info('Indexed function app and found %s functions',
678682
len(indexed_functions))
679683

680684
if indexed_functions:
681685
fx_metadata_results = loader.process_indexed_function(
682686
self._functions,
683-
indexed_functions)
687+
indexed_functions,
688+
function_dir)
684689

685690
indexed_function_logs: List[str] = []
686691
for func in indexed_functions:

azure_functions_worker/loader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def build_variable_interval_retry(retry, max_retry_count, retry_strategy):
121121

122122

123123
def process_indexed_function(functions_registry: functions.Registry,
124-
indexed_functions):
124+
indexed_functions, function_dir):
125125
fx_metadata_results = []
126126
for indexed_function in indexed_functions:
127127
function_info = functions_registry.add_indexed_function(
@@ -134,7 +134,7 @@ def process_indexed_function(functions_registry: functions.Registry,
134134
name=function_info.name,
135135
function_id=function_info.function_id,
136136
managed_dependency_enabled=False, # only enabled for PowerShell
137-
directory=function_info.directory,
137+
directory=function_dir,
138138
script_file=indexed_function.function_script_file,
139139
entry_point=function_info.name,
140140
is_proxy=False, # not supported in V4

tests/endtoend/blueprint_functions/functions_in_blueprint_only/blueprint.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
import time
3+
from datetime import datetime
24

35
import azure.functions as func
46

@@ -29,3 +31,11 @@ def default_template(req: func.HttpRequest) -> func.HttpResponse:
2931
" personalized response.",
3032
status_code=200
3133
)
34+
35+
36+
@bp.route(route="http_func")
37+
def http_func(req: func.HttpRequest) -> func.HttpResponse:
38+
time.sleep(1)
39+
40+
current_time = datetime.now().strftime("%H:%M:%S")
41+
return func.HttpResponse(f"{current_time}")

tests/endtoend/test_worker_process_count_functions.py

+8
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ class TestWorkerProcessCountStein(TestWorkerProcessCount):
6868
def get_script_dir(cls):
6969
return testutils.E2E_TESTS_FOLDER / 'http_functions' /\
7070
'http_functions_stein'
71+
72+
73+
class TestWorkerProcessCountWithBlueprintStein(TestWorkerProcessCount):
74+
75+
@classmethod
76+
def get_script_dir(cls):
77+
return testutils.E2E_TESTS_FOLDER / 'blueprint_functions' /\
78+
'functions_in_blueprint_only'

0 commit comments

Comments
 (0)