You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function is triggered with documents added from specified date and time
Actual Behavior
First of all, it is unclear what the type is of the start_from_time parameter (linked issue). Depending on the type of input a different error message occurs.
When I try a string i.e. "2023-06-01T00:00:00Z" the following error occurs:
The listener for function 'Functions.risicoscores_silver_calculation_models_producer' was unable to start. Microsoft.Azure.Cosmos.Client: StartTime cannot have DateTimeKind.Unspecified (Parameter 'value').
When I try a datetime i.e. datetime.fromisoformat("2023-06-01T00:00:00Z"), the following error occurs:
Worker failed to index functions
[2024-11-12T12:01:43.006Z] Result: Failure
[2024-11-12T12:01:43.006Z] Exception: TypeError: Object of type datetime is not JSON serializable
[2024-11-12T12:01:43.006Z] Stack: File "/usr/lib/azure-functions-core-tools-4/workers/python/3.11/LINUX/X64/azure_functions_worker/dispatcher.py", line 345, in _handle__functions_metadata_request
[2024-11-12T12:01:43.006Z] fx_metadata_results = self.index_functions(function_path)
[2024-11-12T12:01:43.006Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.006Z] File "/usr/lib/azure-functions-core-tools-4/workers/python/3.11/LINUX/X64/azure_functions_worker/dispatcher.py", line 622, in index_functions
[2024-11-12T12:01:43.007Z] fx_metadata_results = loader.process_indexed_function(
[2024-11-12T12:01:43.007Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.007Z] File "/usr/lib/azure-functions-core-tools-4/workers/python/3.11/LINUX/X64/azure_functions_worker/loader.py", line 142, in process_indexed_function
[2024-11-12T12:01:43.007Z] raw_bindings=indexed_function.get_raw_bindings(),
[2024-11-12T12:01:43.007Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.007Z] File "/usr/lib/azure-functions-core-tools-4/workers/python/3.11/LINUX/X64/azure/functions/decorators/function_app.py", line 161, in get_raw_bindings
[2024-11-12T12:01:43.007Z] return [json.dumps(b.get_dict_repr(), cls=StringifyEnumJsonEncoder)
[2024-11-12T12:01:43.007Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.007Z] File "/usr/lib/azure-functions-core-tools-4/workers/python/3.11/LINUX/X64/azure/functions/decorators/function_app.py", line 161, in <listcomp>
[2024-11-12T12:01:43.007Z] return [json.dumps(b.get_dict_repr(), cls=StringifyEnumJsonEncoder)
[2024-11-12T12:01:43.007Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.007Z] File "/usr/lib/python3.11/json/__init__.py", line 238, in dumps
[2024-11-12T12:01:43.007Z] **kw).encode(obj)
[2024-11-12T12:01:43.008Z] ^^^^^^^^^^^
[2024-11-12T12:01:43.008Z] File "/usr/lib/python3.11/json/encoder.py", line 200, in encode
[2024-11-12T12:01:43.008Z] chunks = self.iterencode(o, _one_shot=True)
[2024-11-12T12:01:43.008Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.008Z] File "/usr/lib/python3.11/json/encoder.py", line 258, in iterencode
[2024-11-12T12:01:43.008Z] return _iterencode(o, 0)
[2024-11-12T12:01:43.008Z] ^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.008Z] File "/usr/lib/azure-functions-core-tools-4/workers/python/3.11/LINUX/X64/azure/functions/decorators/utils.py", line 175, in default
[2024-11-12T12:01:43.008Z] return super().default(o)
[2024-11-12T12:01:43.008Z] ^^^^^^^^^^^^^^^^^^
[2024-11-12T12:01:43.008Z] File "/usr/lib/python3.11/json/encoder.py", line 180, in default
[2024-11-12T12:01:43.008Z] raise TypeError(f'Object of type {o.__class__.__name__} '
Steps to Reproduce
Create an azure function with a cosmos db trigger
Add a start_from_time parameter to the trigger decorator
The type is supposed to be str. Can you try using slashes instead of dashes? For example: "2024/11/19T00:00:00Z"
I was able to repro that issue with both V1 and V2 models, so it doesn't look like it's an issue with the decorators. We don't do any parsing or altering of the value passed in the decorator, so it seems like the extension is expecting a particular format. A Node function app works similarly here.
Tbf, I'm not sure why the slashes would be the expected format here. If this also works for you, we can update the docs to mention this. If this format is difficult, we can look into adding some logic in the decorators that will convert a start_from_time input value of "2024-11-19T00:00:00Z" into "2024/11/19T00:00:00Z", but I'd have to confirm with the CosmosDB extension team what the expected format is.
Expected Behavior
The function is triggered with documents added from specified date and time
Actual Behavior
First of all, it is unclear what the type is of the
start_from_time
parameter (linked issue). Depending on the type of input a different error message occurs.When I try a string i.e.
"2023-06-01T00:00:00Z"
the following error occurs:When I try a datetime i.e.
datetime.fromisoformat("2023-06-01T00:00:00Z")
, the following error occurs:Steps to Reproduce
Relevant code being tried
Relevant log output
requirements.txt file
Where are you facing this problem?
Local - Core Tools
Function app name
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: