3232 "/archive/refs/heads/dev.zip"
3333_FUNC_FILE_NAME = "azure-functions-python-library-dev"
3434_CUSTOM_IMAGE = "CUSTOM_IMAGE"
35+ _EXTENSION_BASE_ZIP = 'https://github.com/Azure/azure-functions-python-' \
36+ 'extensions/archive/refs/heads/dev.zip'
3537
3638
3739class LinuxConsumptionWebHostController :
@@ -151,6 +153,15 @@ def _download_azure_functions() -> str:
151153 with ZipFile (BytesIO (zipresp .read ())) as zfile :
152154 zfile .extractall (tempfile .gettempdir ())
153155
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+
154165 def spawn_container (self ,
155166 image : str ,
156167 env : Dict [str , str ] = {}) -> int :
@@ -163,11 +174,24 @@ def spawn_container(self,
163174 # TODO: Mount library in docker container
164175 # self._download_azure_functions()
165176
177+ # Download python extension base package
178+ ext_folder = self ._download_extensions ()
179+
166180 container_worker_path = (
167181 f"/azure-functions-host/workers/python/{ self ._py_version } /"
168182 "LINUX/X64/azure_functions_worker"
169183 )
170184
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+ )
171195 run_cmd = []
172196 run_cmd .extend ([self ._docker_cmd , "run" , "-p" , "0:80" , "-d" ])
173197 run_cmd .extend (["--name" , self ._uuid , "--privileged" ])
@@ -177,6 +201,8 @@ def spawn_container(self,
177201 run_cmd .extend (["-e" , f"CONTAINER_ENCRYPTION_KEY={ _DUMMY_CONT_KEY } " ])
178202 run_cmd .extend (["-e" , "WEBSITE_PLACEHOLDER_MODE=1" ])
179203 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 } ' ])
180206
181207 for key , value in env .items ():
182208 run_cmd .extend (["-e" , f"{ key } ={ value } " ])
0 commit comments