Hi All,
we are trying to use aspose.words (25.7.0) and aspose.slides (25.7.0) in a “plain” Azure Function App (Python 3.12) but as soon as we add the import for these packages the functions do not load anymore. We were able to use them by containerizing the function app project and installing libgdiplus within the dockerfile but we would prefer to use the packages without containers. But since libgdiplus cant be installed on plain Azure Functions host I dont think there is any chance to use it like we intended to do.
Is there any way to use these packages in a “plain” Azure Function App (Python 3.12) without using a container?
Any advice or best practices would be greatly appreciated.
Python packages in question:
Aspose.Words for Python
Aspose.Slides for Python via .NET
Example Dockerfile we used to confirm containerized function app project works:
FROM mcr.microsoft.com/azure-functions/python:4-python3.12
RUN apt-get update &&
apt-get install -y libgdiplus &&
apt-get clean
Example Function we used to confirm containerized function app project works:
import logging
import io
import os
import azure.functions as funcdef main(req: func.HttpRequest) → func.HttpResponse:
“”"
HTTP POST: Accept PPTX bytes in the request body and return PDF.- Content-Type: application/octet-stream - Query param: filename=yourdeck.pptx (optional) """ try: # If GET, provide a simple help message (do not require Aspose import) if req.method.upper() == "GET": return func.HttpResponse( body=b"Aspose endpoint is ready. POST PPTX bytes to receive PDF.", status_code=200, mimetype="text/plain", ) # Validate dependency only for POST try: **import aspose.slides as slides** except ImportError: logging.error("Aspose.Slides not installed. Add 'aspose.slides' to requirements.txt") return func.HttpResponse( body=b'{"error":"Aspose.Slides not installed. Install with pip: aspose.slides"}', status_code=500, mimetype="application/json", ) # Read input (POST) pptx_bytes = req.get_body() or b"" if not pptx_bytes: logging.warning("No PPTX content provided in request body") return func.HttpResponse( body=b'{"error":"No PPTX content provided"}', status_code=400, mimetype="application/json", ) filename = req.params.get("filename", "uploaded.pptx") # Convert PPTX -> PDF pptx_stream = io.BytesIO(pptx_bytes) presentation = slides.Presentation(pptx_stream) pdf_stream = io.BytesIO() presentation.save(pdf_stream, slides.export.SaveFormat.PDF) pdf_bytes = pdf_stream.getvalue() logging.info("Conversion succeeded: %s -> PDF (%d bytes)", filename, len(pdf_bytes)) return func.HttpResponse( body=pdf_bytes, status_code=200, mimetype="application/pdf", headers={ "Content-Disposition": f"inline; filename={os.path.splitext(filename)[0]}.pdf", }, ) except Exception as e: # Top-level catch-all to ensure 500 includes error details and a log entry logging.exception("Unhandled error in Aspose conversion") return func.HttpResponse( body=("{\"error\": \"%s\"}" % str(e)).encode("utf-8"), status_code=500, mimetype="application/json", )