32
32
"/archive/refs/heads/dev.zip"
33
33
_FUNC_FILE_NAME = "azure-functions-python-library-dev"
34
34
_CUSTOM_IMAGE = "CUSTOM_IMAGE"
35
+ _EXTENSION_BASE_ZIP = 'https://github.com/Azure/azure-functions-python-' \
36
+ 'extensions/archive/refs/heads/dev.zip'
35
37
36
38
37
39
class LinuxConsumptionWebHostController :
@@ -151,6 +153,15 @@ def _download_azure_functions() -> str:
151
153
with ZipFile (BytesIO (zipresp .read ())) as zfile :
152
154
zfile .extractall (tempfile .gettempdir ())
153
155
156
+ @staticmethod
157
+ def _download_extensions () -> str :
158
+ folder = tempfile .gettempdir ()
159
+ with urlopen (_EXTENSION_BASE_ZIP ) as zipresp :
160
+ with ZipFile (BytesIO (zipresp .read ())) as zfile :
161
+ zfile .extractall (tempfile .gettempdir ())
162
+
163
+ return folder
164
+
154
165
def spawn_container (self ,
155
166
image : str ,
156
167
env : Dict [str , str ] = {}) -> int :
@@ -163,11 +174,24 @@ def spawn_container(self,
163
174
# TODO: Mount library in docker container
164
175
# self._download_azure_functions()
165
176
177
+ # Download python extension base package
178
+ ext_folder = self ._download_extensions ()
179
+
166
180
container_worker_path = (
167
181
f"/azure-functions-host/workers/python/{ self ._py_version } /"
168
182
"LINUX/X64/azure_functions_worker"
169
183
)
170
184
185
+ base_ext_container_path = (
186
+ f"/azure-functions-host/workers/python/{ self ._py_version } /"
187
+ "LINUX/X64/azurefunctions/extensions/base"
188
+ )
189
+
190
+ base_ext_local_path = (
191
+ f'{ ext_folder } /azure-functions-python'
192
+ '-extensions-dev/azurefunctions-extensions-base'
193
+ '/azurefunctions/extensions/base'
194
+ )
171
195
run_cmd = []
172
196
run_cmd .extend ([self ._docker_cmd , "run" , "-p" , "0:80" , "-d" ])
173
197
run_cmd .extend (["--name" , self ._uuid , "--privileged" ])
@@ -177,6 +201,8 @@ def spawn_container(self,
177
201
run_cmd .extend (["-e" , f"CONTAINER_ENCRYPTION_KEY={ _DUMMY_CONT_KEY } " ])
178
202
run_cmd .extend (["-e" , "WEBSITE_PLACEHOLDER_MODE=1" ])
179
203
run_cmd .extend (["-v" , f'{ worker_path } :{ container_worker_path } ' ])
204
+ run_cmd .extend (["-v" ,
205
+ f'{ base_ext_local_path } :{ base_ext_container_path } ' ])
180
206
181
207
for key , value in env .items ():
182
208
run_cmd .extend (["-e" , f"{ key } ={ value } " ])
0 commit comments