azure-functions-runtime 1.0.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. azure_functions_runtime-1.0.0a1.dist-info/METADATA +159 -0
  2. azure_functions_runtime-1.0.0a1.dist-info/RECORD +48 -0
  3. azure_functions_runtime-1.0.0a1.dist-info/WHEEL +5 -0
  4. azure_functions_runtime-1.0.0a1.dist-info/licenses/LICENSE +21 -0
  5. azure_functions_runtime-1.0.0a1.dist-info/top_level.txt +2 -0
  6. azure_functions_worker_v2/__init__.py +14 -0
  7. azure_functions_worker_v2/bindings/context.py +67 -0
  8. azure_functions_worker_v2/bindings/datumdef.py +232 -0
  9. azure_functions_worker_v2/bindings/generic.py +74 -0
  10. azure_functions_worker_v2/bindings/meta.py +290 -0
  11. azure_functions_worker_v2/bindings/nullable_converters.py +115 -0
  12. azure_functions_worker_v2/bindings/out.py +16 -0
  13. azure_functions_worker_v2/bindings/retrycontext.py +48 -0
  14. azure_functions_worker_v2/bindings/tracecontext.py +44 -0
  15. azure_functions_worker_v2/functions.py +431 -0
  16. azure_functions_worker_v2/handle_event.py +437 -0
  17. azure_functions_worker_v2/http_v2.py +290 -0
  18. azure_functions_worker_v2/loader.py +207 -0
  19. azure_functions_worker_v2/logging.py +16 -0
  20. azure_functions_worker_v2/otel.py +113 -0
  21. azure_functions_worker_v2/utils/__init__.py +2 -0
  22. azure_functions_worker_v2/utils/app_setting_manager.py +29 -0
  23. azure_functions_worker_v2/utils/constants.py +92 -0
  24. azure_functions_worker_v2/utils/current.py +35 -0
  25. azure_functions_worker_v2/utils/env_state.py +75 -0
  26. azure_functions_worker_v2/utils/helpers.py +28 -0
  27. azure_functions_worker_v2/utils/tracing.py +54 -0
  28. azure_functions_worker_v2/utils/typing_inspect.py +295 -0
  29. azure_functions_worker_v2/utils/validators.py +20 -0
  30. azure_functions_worker_v2/utils/wrappers.py +50 -0
  31. azure_functions_worker_v2/version.py +4 -0
  32. tests/protos/FunctionRpc_pb2.py +215 -0
  33. tests/protos/FunctionRpc_pb2_grpc.py +69 -0
  34. tests/protos/__init__.py +43 -0
  35. tests/protos/identity/ClaimsIdentityRpc_pb2.py +29 -0
  36. tests/protos/identity/ClaimsIdentityRpc_pb2_grpc.py +4 -0
  37. tests/protos/identity/__init__.py +0 -0
  38. tests/protos/shared/NullableTypes_pb2.py +33 -0
  39. tests/protos/shared/NullableTypes_pb2_grpc.py +4 -0
  40. tests/protos/shared/__init__.py +0 -0
  41. tests/unittests/basic_function/function_app.py +44 -0
  42. tests/unittests/indexing_exception_function/function_app.py +35 -0
  43. tests/unittests/streaming_function/function_app.py +100 -0
  44. tests/unittests/test_code_quality.py +54 -0
  45. tests/unittests/test_handle_event.py +233 -0
  46. tests/utils/__init__.py +2 -0
  47. tests/utils/constants.py +7 -0
  48. tests/utils/testutils.py +34 -0
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: azure-functions-runtime
3
+ Version: 1.0.0a1
4
+ Summary: Python Language Worker for Azure Functions Runtime
5
+ Author-email: "Azure Functions team at Microsoft Corp." <azurefunctions@microsoft.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) Microsoft Corporation. All rights reserved.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE
27
+
28
+ Project-URL: Documentation, https://github.com/Azure/azure-functions-python-worker?tab=readme-ov-file#-azure-functions-python-worker
29
+ Project-URL: Repository, https://github.com/Azure/azure-functions-python-worker
30
+ Keywords: azure,functions,azurefunctions,python,serverless
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.13
35
+ Classifier: Operating System :: Microsoft :: Windows
36
+ Classifier: Operating System :: POSIX
37
+ Classifier: Operating System :: MacOS :: MacOS X
38
+ Classifier: Environment :: Web Environment
39
+ Classifier: License :: OSI Approved :: MIT License
40
+ Classifier: Intended Audience :: Developers
41
+ Requires-Python: >=3.13
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Requires-Dist: azurefunctions-extensions-base; python_version >= "3.8"
45
+ Requires-Dist: azure-functions
46
+ Provides-Extra: dev
47
+ Requires-Dist: azure-eventhub; extra == "dev"
48
+ Requires-Dist: azure-functions-durable; extra == "dev"
49
+ Requires-Dist: azure-monitor-opentelemetry; python_version >= "3.8" and extra == "dev"
50
+ Requires-Dist: flask; extra == "dev"
51
+ Requires-Dist: fastapi~=0.103.2; extra == "dev"
52
+ Requires-Dist: pydantic; extra == "dev"
53
+ Requires-Dist: pycryptodome==3.*; extra == "dev"
54
+ Requires-Dist: flake8==5.*; python_version == "3.7" and extra == "dev"
55
+ Requires-Dist: flake8==6.*; python_version >= "3.8" and extra == "dev"
56
+ Requires-Dist: mypy; extra == "dev"
57
+ Requires-Dist: pytest; extra == "dev"
58
+ Requires-Dist: requests==2.*; extra == "dev"
59
+ Requires-Dist: coverage; extra == "dev"
60
+ Requires-Dist: grpcio~=1.70.0; extra == "dev"
61
+ Requires-Dist: grpcio-tools~=1.70.0; extra == "dev"
62
+ Requires-Dist: pytest-sugar; extra == "dev"
63
+ Requires-Dist: opentelemetry-api; python_version >= "3.8" and extra == "dev"
64
+ Requires-Dist: pytest-cov; extra == "dev"
65
+ Requires-Dist: pytest-xdist; extra == "dev"
66
+ Requires-Dist: pytest-randomly; extra == "dev"
67
+ Requires-Dist: pytest-instafail; extra == "dev"
68
+ Requires-Dist: pytest-rerunfailures; extra == "dev"
69
+ Requires-Dist: ptvsd; extra == "dev"
70
+ Requires-Dist: python-dotenv; extra == "dev"
71
+ Requires-Dist: plotly; extra == "dev"
72
+ Requires-Dist: scikit-learn; extra == "dev"
73
+ Requires-Dist: opencv-python; extra == "dev"
74
+ Requires-Dist: pandas; extra == "dev"
75
+ Requires-Dist: numpy; extra == "dev"
76
+ Requires-Dist: pre-commit; extra == "dev"
77
+ Requires-Dist: invoke; extra == "dev"
78
+ Provides-Extra: test-http-v2
79
+ Requires-Dist: azurefunctions-extensions-http-fastapi==1.0.0b2; extra == "test-http-v2"
80
+ Requires-Dist: ujson; extra == "test-http-v2"
81
+ Requires-Dist: orjson; extra == "test-http-v2"
82
+ Provides-Extra: test-deferred-bindings
83
+ Requires-Dist: azurefunctions-extensions-bindings-blob==1.0.0b3; extra == "test-deferred-bindings"
84
+ Dynamic: license-file
85
+
86
+ # <img src="https://raw.githubusercontent.com/Azure/azure-functions-python-worker/dev/docs/Azure.Functions.svg" width = "30" alt="Functions Header Image - Lightning Logo"> Azure Functions Python Worker
87
+
88
+ | Branch | Build Status | CodeCov | Test Status |
89
+ |--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
90
+ | dev | [![Build Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) | [![codecov](https://codecov.io/gh/Azure/azure-functions-python-worker/branch/dev/graph/badge.svg)](https://codecov.io/gh/Azure/azure-functions-python-worker) | [![Test Status](https://img.shields.io/azure-devops/build/azfunc/public/658/dev)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=658&branchName=dev) |
91
+
92
+ Python support for Azure Functions is based on Python 3.8, 3.9, 3.10, 3.11, and 3.12 serverless hosting on Linux and the Functions 4.0 runtime.
93
+
94
+ Here is the current status of Python in Azure Functions:
95
+
96
+ What are the supported Python versions?
97
+
98
+ | Azure Functions Runtime | Python 3.8 | Python 3.9 | Python 3.10 | Python 3.11 | Python 3.12 |
99
+ |----------------------------------|------------|------------|-------------|-------------|-------------|
100
+ | Azure Functions 3.0 (deprecated) | ✔ | ✔ | - | - | - |
101
+ | Azure Functions 4.0 | ✔ | ✔ | ✔ | ✔ | ✔ |
102
+
103
+ For information about Azure Functions Runtime, please refer to [Azure Functions runtime versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions) page.
104
+
105
+ ### What's available?
106
+
107
+ - Build, test, debug, and publish using Azure Functions Core Tools (CLI) or Visual Studio Code
108
+ - Deploy Python Function project onto consumption, dedicated, elastic premium, or flex consumption plan.
109
+ - Deploy Python Function project in a custom docker image onto dedicated or elastic premium plan.
110
+ - Triggers / Bindings : Blob, Cosmos DB, Event Grid, Event Hub, HTTP, Kafka, MySQL, Queue, ServiceBus, SQL, Timer, and Warmup
111
+ - Triggers / Bindings : Custom binding support
112
+
113
+ ### What's new?
114
+
115
+ - [SDK Type Bindings for Blob](https://techcommunity.microsoft.com/t5/azure-compute-blog/azure-functions-sdk-type-bindings-for-azure-blob-storage-with/ba-p/4146744)
116
+ - [HTTP Streaming](https://techcommunity.microsoft.com/t5/azure-compute-blog/azure-functions-support-for-http-streams-in-python-is-now-in/ba-p/4146697)
117
+
118
+ ### Get Started
119
+
120
+ - [Create your first Python function](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python)
121
+ - [Developer guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python)
122
+ - [Binding API reference](https://docs.microsoft.com/en-us/python/api/azure-functions/azure.functions?view=azure-python)
123
+ - [Develop using VS Code](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code)
124
+ - [Create a Python Function on Linux using a custom docker image](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image)
125
+
126
+ # Give Feedback
127
+
128
+ Issues and feature requests are tracked in a variety of places. To report this feedback, please file an issue to the relevant repository below:
129
+
130
+ | Item | Description | Link |
131
+ |---------------|----------------------------------------------|--------------------------------------------------------------------------------|
132
+ | Python Worker | Programming Model, Triggers & Bindings | [File an Issue](https://github.com/Azure/azure-functions-python-worker/issues) |
133
+ | Linux | Base Docker Images | [File an Issue](https://github.com/Azure/azure-functions-docker/issues) |
134
+ | Runtime | Script Host & Language Extensibility | [File an Issue](https://github.com/Azure/azure-functions-host/issues) |
135
+ | VSCode | VSCode Extension for Azure Functions | [File an Issue](https://github.com/microsoft/vscode-azurefunctions/issues) |
136
+ | Core Tools | Command Line Interface for Local Development | [File an Issue](https://github.com/Azure/azure-functions-core-tools/issues) |
137
+ | Portal | User Interface or Experience Issue | [File an Issue](https://github.com/azure/azure-functions-ux/issues) |
138
+ | Templates | Code Issues with Creation Template | [File an Issue](https://github.com/Azure/azure-functions-templates/issues) |
139
+
140
+ # Contribute
141
+
142
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a
143
+ Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
144
+ the rights to use your contribution. For details, visit https://cla.microsoft.com.
145
+
146
+ Here are some pointers to get started:
147
+
148
+ - [Language worker architecture](https://github.com/Azure/azure-functions-python-worker/wiki/Worker-Architecture)
149
+ - [Setting up the development environment](https://github.com/Azure/azure-functions-python-worker/wiki/Contributor-Guide)
150
+ - [Adding support for a new binding](https://github.com/Azure/azure-functions-python-worker/wiki/Adding-support-for-a-new-binding-type)
151
+ - [Release instructions](https://github.com/Azure/azure-functions-python-worker/wiki/Release-Instructions)
152
+
153
+ When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
154
+ a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
155
+ provided by the bot. You will only need to do this once across all repos using our CLA.
156
+
157
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
158
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
159
+ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
@@ -0,0 +1,48 @@
1
+ azure_functions_runtime-1.0.0a1.dist-info/licenses/LICENSE,sha256=3qkmU0GCkALiwjpzcjk-su1uJghftiPzikugr4M_MKY,1183
2
+ azure_functions_worker_v2/__init__.py,sha256=062OR-gFOD8yyKB0nlEdYSGHwDq3_wvjVWMTFFgTyIs,568
3
+ azure_functions_worker_v2/functions.py,sha256=t8wl91Wq4vi-MmnNirj35Ls9nbL6vGOk_VfqKJX_lJA,17823
4
+ azure_functions_worker_v2/handle_event.py,sha256=XdjtukJ6BCKnIvPhlxpR01h4KlMw5tmEEVCdRTw5GJ8,17432
5
+ azure_functions_worker_v2/http_v2.py,sha256=Rk_d-xFDa_dlZBw-DzTQ-mSIKKbtY9cqp-XBNfhbxJc,9598
6
+ azure_functions_worker_v2/loader.py,sha256=5i49ufqcZ3LKA-A7ZD2XTFIMg_WwDB1xZD1tvGf5XiI,7669
7
+ azure_functions_worker_v2/logging.py,sha256=Pu2GUuAyARf0OAxaSeEOP1NgRhujtadjcwOf5s4eGH0,425
8
+ azure_functions_worker_v2/otel.py,sha256=lSaR3Ld1_9R1YtUHo6M0ykzqdxORRyw8aKK2qOSW9RY,3927
9
+ azure_functions_worker_v2/version.py,sha256=Zs_2LYsSjoSUyFMKqxcWLQcw31-n-1LAmwRdzHw-cEo,119
10
+ azure_functions_worker_v2/bindings/context.py,sha256=rOFY2wmyZ_tqd1e1Uoabb953bKhPAzTxWlXD-UZRCPY,2094
11
+ azure_functions_worker_v2/bindings/datumdef.py,sha256=uU6aW0pqJDyVaXiGk9vQKe8WgBOZgpPav6CjSyB93u4,8559
12
+ azure_functions_worker_v2/bindings/generic.py,sha256=FjgqAp-A89io9HxPDTqcC9zFu5N5zgdSzndeIB8t4Jg,2381
13
+ azure_functions_worker_v2/bindings/meta.py,sha256=ApqmKQLLPS7CysP9FNZwRZ2Rt8BMoOHuT_cva8Af-Lk,10575
14
+ azure_functions_worker_v2/bindings/nullable_converters.py,sha256=5UTM6JOAUSjSqahgUJB-DeKoWs9VkLkcVC4TSk8yALg,4638
15
+ azure_functions_worker_v2/bindings/out.py,sha256=N662R8t_LbDIFxlyk__yD-XTNrQXLu5L2gUExy4e6cI,330
16
+ azure_functions_worker_v2/bindings/retrycontext.py,sha256=jde9bH-HRTYDlWh_zOnfe6sk3Mb7xdHT5uS7yEjK_bI,1177
17
+ azure_functions_worker_v2/bindings/tracecontext.py,sha256=YKXHa8AH9pl1o4OXR_kV6W8WP1AMqZ-o5SEeET1yzXg,1341
18
+ azure_functions_worker_v2/utils/__init__.py,sha256=5K7xjH5l065Dv7kNZIQDG5mwE1Ua6i_WoRBc0NdSGfE,96
19
+ azure_functions_worker_v2/utils/app_setting_manager.py,sha256=8HVV7Oc4lqjD-r0h_AiQCj5INGyuUAxtIlFnSh8ad4I,891
20
+ azure_functions_worker_v2/utils/constants.py,sha256=m4p_HVbS14pwFPAenceoPILm2eeKayG-MOT8XJg1Qas,3295
21
+ azure_functions_worker_v2/utils/current.py,sha256=9Yyeo1uJyJhbtM5MAm1-OdRr-EQyOEpOhxpRmDJT_8c,1033
22
+ azure_functions_worker_v2/utils/env_state.py,sha256=hQTQpynUV1J11MsZwRdOo6le_49ObOcw3F0EG2v-2Os,2185
23
+ azure_functions_worker_v2/utils/helpers.py,sha256=RxfMgv22nUbq8uKQJMlA28cKOlf-Kzs9QOQTcu3hI8w,826
24
+ azure_functions_worker_v2/utils/tracing.py,sha256=Zr8jCtbgOZxmxJbrw6SB96SxVr-T7UpXxSvrT_Wfup8,2045
25
+ azure_functions_worker_v2/utils/typing_inspect.py,sha256=JU3_L-XZwPRibgme_LjYmJUMbET41StZr13-_QyNUMo,10550
26
+ azure_functions_worker_v2/utils/validators.py,sha256=x5wlXdgf3CzJjYhZcIPwbSmF4H8S5q8pD4euCz6mMec,650
27
+ azure_functions_worker_v2/utils/wrappers.py,sha256=RKPCqeMPgtpM2anCufXG3fZbFdkFUxmpws2Vl9eXjXs,1685
28
+ tests/protos/FunctionRpc_pb2.py,sha256=dH7Ift7RRqDkKRJWByBKVPvcOo48W6B-QLPRU61qCuo,31838
29
+ tests/protos/FunctionRpc_pb2_grpc.py,sha256=tee_r12tGFEr6sBZRkrV44b5xxQ29On_UlNCeeTG0Ek,2585
30
+ tests/protos/__init__.py,sha256=KK9SIRyd5P68ZCT7S9j1txtfbpFn3qR-Wj0BuN6J89I,1045
31
+ tests/protos/identity/ClaimsIdentityRpc_pb2.py,sha256=IaCfcCQVY0UpTqsSQjcpSJvGxdlujXoCb1iX5aww4N4,1729
32
+ tests/protos/identity/ClaimsIdentityRpc_pb2_grpc.py,sha256=_bXoS025FcWrXR1E_3Mh4GHB1RMvgz8lIpit-Awnf-s,163
33
+ tests/protos/identity/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ tests/protos/shared/NullableTypes_pb2.py,sha256=TFqu3qqe3W4z_4xmta-OAZ8VC-IcGjbbGL0mI0Ab3Gw,1941
35
+ tests/protos/shared/NullableTypes_pb2_grpc.py,sha256=_bXoS025FcWrXR1E_3Mh4GHB1RMvgz8lIpit-Awnf-s,163
36
+ tests/protos/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ tests/unittests/test_code_quality.py,sha256=6os5tW1W4iGExzl7g6DuocZyemn4lOtAJcrFSwFZeyw,1934
38
+ tests/unittests/test_handle_event.py,sha256=FomTNf0pcw43IlnzxOTOQLOEUx_c180HzzzbWANmsfY,13479
39
+ tests/unittests/basic_function/function_app.py,sha256=3DoDercnRP0Sv1fCU-We5RRbf1mRrsWkptSZBmqsbMU,1293
40
+ tests/unittests/indexing_exception_function/function_app.py,sha256=CyINfL9eK2Qz-X97NUE4pP46J-UgkU8DEIP8hAHV0MQ,1064
41
+ tests/unittests/streaming_function/function_app.py,sha256=nQj96pLRHo4uOFafb96fiu8lWZymc7X3gsaxERfyTMQ,2963
42
+ tests/utils/__init__.py,sha256=5K7xjH5l065Dv7kNZIQDG5mwE1Ua6i_WoRBc0NdSGfE,96
43
+ tests/utils/constants.py,sha256=_mP4nreQsZhuI80l7XlqRP_Mz8heC3rF6CHe1hbnfQs,271
44
+ tests/utils/testutils.py,sha256=Eh4drRUq3gffe-PFxZcPpMgO3lqYursfKDvZze_5Xgs,936
45
+ azure_functions_runtime-1.0.0a1.dist-info/METADATA,sha256=emg1RYRZ7LHFyBW8DhhgNsicDh_Fr48JwPJ0WAnJJEA,11541
46
+ azure_functions_runtime-1.0.0a1.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
47
+ azure_functions_runtime-1.0.0a1.dist-info/top_level.txt,sha256=DuZpe1sZJ-8Wh514jCNx4sOz_MC0fM_8B_OZifTGA_c,32
48
+ azure_functions_runtime-1.0.0a1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (79.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,2 @@
1
+ azure_functions_worker_v2
2
+ tests
@@ -0,0 +1,14 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+
4
+ from .handle_event import (worker_init_request,
5
+ functions_metadata_request,
6
+ function_environment_reload_request,
7
+ invocation_request,
8
+ function_load_request)
9
+
10
+ __all__ = ('worker_init_request',
11
+ 'functions_metadata_request',
12
+ 'function_environment_reload_request',
13
+ 'invocation_request',
14
+ 'function_load_request')
@@ -0,0 +1,67 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+ import threading
4
+ from typing import Type
5
+
6
+ from .retrycontext import RetryContext
7
+ from .tracecontext import TraceContext
8
+
9
+
10
+ class Context:
11
+ def __init__(self,
12
+ func_name: str,
13
+ func_dir: str,
14
+ invocation_id: str,
15
+ thread_local_storage: Type[threading.local],
16
+ trace_context: TraceContext,
17
+ retry_context: RetryContext) -> None:
18
+ self.__func_name = func_name
19
+ self.__func_dir = func_dir
20
+ self.__invocation_id = invocation_id
21
+ self.__thread_local_storage = thread_local_storage
22
+ self.__trace_context = trace_context
23
+ self.__retry_context = retry_context
24
+
25
+ @property
26
+ def invocation_id(self) -> str:
27
+ return self.__invocation_id
28
+
29
+ @property
30
+ def thread_local_storage(self) -> Type[threading.local]:
31
+ return self.__thread_local_storage
32
+
33
+ @property
34
+ def function_name(self) -> str:
35
+ return self.__func_name
36
+
37
+ @property
38
+ def function_directory(self) -> str:
39
+ return self.__func_dir
40
+
41
+ @property
42
+ def trace_context(self) -> TraceContext:
43
+ return self.__trace_context
44
+
45
+ @property
46
+ def retry_context(self) -> RetryContext:
47
+ return self.__retry_context
48
+
49
+
50
+ def get_context(invoc_request, name: str,
51
+ directory: str) -> Context:
52
+ """ For more information refer:
53
+ https://aka.ms/azfunc-invocation-context
54
+ """
55
+ trace_context = TraceContext(
56
+ invoc_request.trace_context.trace_parent,
57
+ invoc_request.trace_context.trace_state,
58
+ invoc_request.trace_context.attributes)
59
+
60
+ retry_context = RetryContext(
61
+ invoc_request.retry_context.retry_count,
62
+ invoc_request.retry_context.max_retry_count,
63
+ invoc_request.retry_context.exception)
64
+
65
+ return Context(
66
+ name, directory, invoc_request.invocation_id,
67
+ threading.local(), trace_context, retry_context)
@@ -0,0 +1,232 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+ import json
4
+ import logging
5
+
6
+ from datetime import datetime
7
+ from typing import Any, List, Optional
8
+
9
+ from .nullable_converters import (
10
+ to_nullable_bool,
11
+ to_nullable_double,
12
+ to_nullable_string,
13
+ to_nullable_timestamp,
14
+ )
15
+
16
+ try:
17
+ from http.cookies import SimpleCookie
18
+ except ImportError:
19
+ from Cookie import SimpleCookie # type: ignore
20
+
21
+
22
+ class Datum:
23
+ def __init__(self, value, type):
24
+ self.value = value
25
+ self.type = type
26
+
27
+ @property
28
+ def python_value(self) -> Any:
29
+ if self.value is None or self.type is None:
30
+ return None
31
+ elif self.type in ('bytes', 'string', 'int', 'double'):
32
+ return self.value
33
+ elif self.type == 'json':
34
+ return json.loads(self.value)
35
+ elif self.type == 'collection_string':
36
+ return [v for v in self.value.string]
37
+ elif self.type == 'collection_bytes':
38
+ return [v for v in self.value.bytes]
39
+ elif self.type == 'collection_double':
40
+ return [v for v in self.value.double]
41
+ elif self.type == 'collection_sint64':
42
+ return [v for v in self.value.sint64]
43
+ else:
44
+ return self.value
45
+
46
+ @property
47
+ def python_type(self) -> type:
48
+ return type(self.python_value)
49
+
50
+ def __eq__(self, other):
51
+ if not isinstance(other, type(self)):
52
+ return False
53
+
54
+ return self.value == other.value and self.type == other.type
55
+
56
+ def __hash__(self):
57
+ return hash((type(self), (self.value, self.type)))
58
+
59
+ def __repr__(self):
60
+ val_repr = repr(self.value)
61
+ if len(val_repr) > 10:
62
+ val_repr = val_repr[:10] + '...'
63
+ return '<Datum ' + str(self.type) + val_repr + '>'
64
+
65
+ @classmethod
66
+ def from_typed_data(cls, protos):
67
+ try:
68
+ td = protos.TypedData
69
+ except Exception:
70
+ td = protos
71
+ tt = td.WhichOneof('data')
72
+ if tt == 'http':
73
+ http = td.http
74
+ val = dict(
75
+ method=Datum(http.method, 'string'),
76
+ url=Datum(http.url, 'string'),
77
+ headers={
78
+ k: Datum(v, 'string') for k, v in http.headers.items()
79
+ },
80
+ body=(
81
+ Datum.from_typed_data(http.body)
82
+ or Datum(type='bytes', value=b'')
83
+ ),
84
+ params={
85
+ k: Datum(v, 'string') for k, v in http.params.items()
86
+ },
87
+ query={
88
+ k: Datum(v, 'string') for k, v in http.query.items()
89
+ },
90
+ )
91
+ elif tt == 'string':
92
+ val = td.string
93
+ elif tt == 'bytes':
94
+ val = td.bytes
95
+ elif tt == 'json':
96
+ val = td.json
97
+ elif tt == 'collection_bytes':
98
+ val = td.collection_bytes
99
+ elif tt == 'collection_string':
100
+ val = td.collection_string
101
+ elif tt == 'collection_sint64':
102
+ val = td.collection_sint64
103
+ elif tt == 'model_binding_data':
104
+ val = td.model_binding_data
105
+ elif tt == 'collection_model_binding_data':
106
+ val = td.collection_model_binding_data
107
+ elif tt is None:
108
+ return None
109
+ else:
110
+ raise NotImplementedError(
111
+ 'unsupported TypeData kind: %s' % tt
112
+ )
113
+
114
+ return cls(val, tt)
115
+
116
+
117
+ def datum_as_proto(datum: Datum, protos):
118
+ if datum.type == 'string':
119
+ return protos.TypedData(string=datum.value)
120
+ elif datum.type == 'bytes':
121
+ return protos.TypedData(bytes=datum.value)
122
+ elif datum.type == 'json':
123
+ return protos.TypedData(json=datum.value)
124
+ elif datum.type == 'http':
125
+ return protos.TypedData(http=protos.RpcHttp(
126
+ status_code=datum.value['status_code'].value,
127
+ headers={
128
+ k: v.value
129
+ for k, v in datum.value['headers'].items()
130
+ },
131
+ cookies=parse_to_rpc_http_cookie_list(datum.value.get('cookies'), protos),
132
+ enable_content_negotiation=False,
133
+ body=datum_as_proto(datum.value['body'], protos),
134
+ ))
135
+ elif datum.type is None:
136
+ return None
137
+ elif datum.type == 'dict':
138
+ # TypedData doesn't support dict, so we return it as json
139
+ return protos.TypedData(json=json.dumps(datum.value))
140
+ elif datum.type == 'list':
141
+ # TypedData doesn't support list, so we return it as json
142
+ return protos.TypedData(json=json.dumps(datum.value))
143
+ elif datum.type == 'int':
144
+ return protos.TypedData(int=datum.value)
145
+ elif datum.type == 'double':
146
+ return protos.TypedData(double=datum.value)
147
+ elif datum.type == 'bool':
148
+ # TypedData doesn't support bool, so we return it as an int
149
+ return protos.TypedData(int=int(datum.value))
150
+ else:
151
+ raise NotImplementedError(
152
+ 'unexpected Datum type: %s' % datum.type
153
+ )
154
+
155
+
156
+ def parse_to_rpc_http_cookie_list(cookies: Optional[List[SimpleCookie]], protos):
157
+ if cookies is None:
158
+ return cookies
159
+
160
+ rpc_http_cookies = []
161
+
162
+ for cookie in cookies:
163
+ for name, cookie_entity in cookie.items():
164
+ rpc_http_cookies.append(
165
+ protos.RpcHttpCookie(name=name,
166
+ value=cookie_entity.value,
167
+ domain=to_nullable_string(
168
+ cookie_entity['domain'],
169
+ 'cookie.domain',
170
+ protos),
171
+ path=to_nullable_string(
172
+ cookie_entity['path'],
173
+ 'cookie.path',
174
+ protos),
175
+ expires=to_nullable_timestamp(
176
+ parse_cookie_attr_expires(
177
+ cookie_entity), 'cookie.expires',
178
+ protos),
179
+ secure=to_nullable_bool(
180
+ bool(cookie_entity['secure']),
181
+ 'cookie.secure',
182
+ protos),
183
+ http_only=to_nullable_bool(
184
+ bool(cookie_entity['httponly']),
185
+ 'cookie.httpOnly',
186
+ protos),
187
+ same_site=parse_cookie_attr_same_site(
188
+ cookie_entity, protos),
189
+ max_age=to_nullable_double(
190
+ cookie_entity['max-age'],
191
+ 'cookie.maxAge',
192
+ protos)))
193
+
194
+ return rpc_http_cookies
195
+
196
+
197
+ def parse_cookie_attr_expires(cookie_entity):
198
+ expires = cookie_entity['expires']
199
+
200
+ if expires is not None and len(expires) != 0:
201
+ try:
202
+ return datetime.strptime(expires, "%a, %d %b %Y %H:%M:%S GMT")
203
+ except ValueError:
204
+ logging.error(
205
+ "Can not parse value %s of expires in the cookie "
206
+ "due to invalid format.", expires)
207
+ raise
208
+ except OverflowError:
209
+ logging.error(
210
+ "Can not parse value %s of expires in the cookie "
211
+ "because the parsed date exceeds the largest valid C "
212
+ "integer on your system.", expires)
213
+ raise
214
+
215
+ return None
216
+
217
+
218
+ def parse_cookie_attr_same_site(cookie_entity, protos):
219
+ same_site = getattr(protos.RpcHttpCookie.SameSite, "None")
220
+ try:
221
+ raw_same_site_str = cookie_entity['samesite'].lower()
222
+
223
+ if raw_same_site_str == 'lax':
224
+ same_site = protos.RpcHttpCookie.SameSite.Lax
225
+ elif raw_same_site_str == 'strict':
226
+ same_site = protos.RpcHttpCookie.SameSite.Strict
227
+ elif raw_same_site_str == 'none':
228
+ same_site = protos.RpcHttpCookie.SameSite.ExplicitNone
229
+ except Exception:
230
+ return same_site
231
+
232
+ return same_site
@@ -0,0 +1,74 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+ import typing
4
+ from typing import Any, Optional
5
+
6
+ from .datumdef import Datum
7
+
8
+
9
+ class GenericBinding:
10
+
11
+ @classmethod
12
+ def has_trigger_support(cls) -> bool:
13
+ return False
14
+
15
+ @classmethod
16
+ def check_input_type_annotation(cls, pytype: type) -> bool:
17
+ return issubclass(pytype, (str, bytes))
18
+
19
+ @classmethod
20
+ def check_output_type_annotation(cls, pytype: type) -> bool:
21
+ return issubclass(pytype, (str, bytes, bytearray))
22
+
23
+ @classmethod
24
+ def encode(cls, obj: Any, *,
25
+ expected_type: Optional[type]) -> Datum:
26
+ if isinstance(obj, str):
27
+ return Datum(type='string', value=obj)
28
+
29
+ elif isinstance(obj, (bytes, bytearray)):
30
+ return Datum(type='bytes', value=bytes(obj))
31
+ elif obj is None:
32
+ return Datum(type=None, value=obj)
33
+ elif isinstance(obj, dict):
34
+ return Datum(type='dict', value=obj)
35
+ elif isinstance(obj, list):
36
+ return Datum(type='list', value=obj)
37
+ elif isinstance(obj, int):
38
+ return Datum(type='int', value=obj)
39
+ elif isinstance(obj, float):
40
+ return Datum(type='double', value=obj)
41
+ elif isinstance(obj, bool):
42
+ return Datum(type='bool', value=obj)
43
+ else:
44
+ raise NotImplementedError
45
+
46
+ @classmethod
47
+ def decode(cls, data: Datum, *, trigger_metadata) -> typing.Any:
48
+ # Enabling support for Dapr bindings
49
+ # https://github.com/Azure/azure-functions-python-worker/issues/1316
50
+ if data is None:
51
+ return None
52
+ data_type = data.type
53
+
54
+ if data_type == 'string':
55
+ result = data.value
56
+ elif data_type == 'bytes':
57
+ result = data.value
58
+ elif data_type == 'json':
59
+ result = data.value
60
+ elif data_type is None:
61
+ result = None
62
+ else:
63
+ raise ValueError(
64
+ 'unexpected type of data received for the "generic" binding ',
65
+ repr(data_type)
66
+ )
67
+
68
+ return result
69
+
70
+ @classmethod
71
+ def has_implicit_output(cls, bind_name: Optional[str]) -> bool:
72
+ if bind_name == 'durableClient':
73
+ return False
74
+ return True