skip to Main Content

I’m attempting to publish an Azure Function using Python 3.9.12 and include the snowflake-snowpark-python library. However, as soon as I import the library and deploy the Azure Function, it no longer appears in the Function App portal. (The function shows up as soon as I publish the code without importing the snowflake-snowpark-python library).

Here are the import lines

from snowflake.snowpark.session import Session
from snowflake.snowpark.functions import when_matched, when_not_matched,col

Here are the library versions I am using:

aiohappyeyeballs==2.4.4
aiohttp==3.11.10
aiosignal==1.3.1
asn1crypto==1.5.1
async-timeout==5.0.1
attrs==24.2.0
azure-functions==1.21.3
azure-functions-durable==1.2.10
beautifulsoup4==4.12.3
boto3==1.35.77
botocore==1.35.77
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.4.0
cloudpickle==2.0.0
cryptography==44.0.0
filelock==3.16.1
frozenlist==1.5.0
furl==2.1.3
greenlet==3.1.1
idna==3.10
jmespath==1.0.1
lxml==5.3.0
multidict==6.1.0
numpy==1.25.2
orderedmultidict==1.0.1
packaging==24.2
pandas==2.0.3
platformdirs==4.3.6
propcache==0.2.1
protobuf==5.29.1
pyarrow==18.1.0
pycparser==2.22
PyJWT==2.10.1
pyodbc==4.0.39
pyOpenSSL==24.3.0
python-dateutil==2.9.0.post0
pytz==2024.2
PyYAML==6.0.2
redshift-connector==2.1.4
requests==2.32.3
s3transfer==0.10.4
scramp==1.4.5
six==1.17.0
snowflake-connector-python==3.12.3
snowflake-snowpark-python==1.5.0
snowflake-sqlalchemy==1.5.1
sortedcontainers==2.4.0
soupsieve==2.6
SQLAlchemy==1.4.7
tomlkit==0.13.2
typing_extensions==4.12.2
tzdata==2024.2
tzlocal==5.2
urllib3==1.26.20
yarl==1.18.3

I have also tested multiple versions of the snowflake-snowpark-python library, but all of them result in the same issue. I am using 1.5.0 because snowflake-snowpark-python’s official documentation recommends that version.
Is there a version I can use which would allow me to publish the Azure function as expected?

P.S. – There are no warnings or errors during the publishing process. Is there a way to debug why the function isn’t appearing in the portal, even though the deployment shows no errors?

My function code:

# Register this blueprint by adding the following line of code 
# to your entry point file.  
# app.register_functions(blueprint) 
# 
# Please refer to https://aka.ms/azure-functions-python-blueprints


import azure.functions as func
import logging
from snowflake.snowpark.session import Session
from sqlalchemy.engine import URL
import os
import pandas as pd
import redshift_connector as connector
import json
from snowflake.snowpark.session import Session
from snowflake.snowpark.functions import when_matched, when_not_matched,col


blueprint = func.Blueprint()


@blueprint.route(route="http_trigger", auth_level=func.AuthLevel.FUNCTION)
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = req.params.get('name')
    if not name:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            name = req_body.get('name')

    if name:
        return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
    else:
        return func.HttpResponse(
             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
             status_code=200
        )

SOLUTION:
The issue was due to a library called cryptography, which is a dependency of snowflake.snowpark.
To fix it I reverted the library version to 43.0.3.
You can follow the issue here.

2

Answers


  1. Chosen as BEST ANSWER

    The issue was due to a library called cryptography, which is a dependency of snowflake.snowpark. To fix it I reverted the library version to 43.0.3. You can follow the issue here.


  2. Install the package snowflake-snowpark-python version 1.25.0 and cloudpickle version 2.2.1.

    I have updated the requirements.txt as below:

    aiohappyeyeballs==2.4.4
    aiohttp==3.11.10
    aiosignal==1.3.1
    asn1crypto==1.5.1
    async-timeout==5.0.1
    attrs==24.2.0
    azure-functions==1.21.3
    azure-functions-durable==1.2.10
    beautifulsoup4==4.12.3
    boto3==1.35.77
    botocore==1.35.77
    certifi==2024.8.30
    cffi==1.17.1
    charset-normalizer==3.4.0
    cloudpickle==2.2.1
    cryptography==44.0.0
    filelock==3.16.1
    frozenlist==1.5.0
    furl==2.1.3
    greenlet==3.1.1
    idna==3.10
    jmespath==1.0.1
    lxml==5.3.0
    multidict==6.1.0
    numpy==1.25.2
    orderedmultidict==1.0.1
    packaging==24.2
    pandas==2.0.3
    platformdirs==4.3.6
    propcache==0.2.1
    protobuf==5.29.1
    pyarrow==18.1.0
    pycparser==2.22
    PyJWT==2.10.1
    pyodbc==4.0.39
    pyOpenSSL==24.3.0
    python-dateutil==2.9.0.post0
    pytz==2024.2
    PyYAML==6.0.2
    redshift-connector==2.1.4
    requests==2.32.3
    s3transfer==0.10.4
    scramp==1.4.5
    six==1.17.0
    snowflake-connector-python==3.12.3
    snowflake-snowpark-python==1.25.0
    snowflake-sqlalchemy==1.5.1
    sortedcontainers==2.4.0
    soupsieve==2.6
    SQLAlchemy==1.4.7
    tomlkit==0.13.2
    typing_extensions==4.12.2
    tzdata==2024.2
    tzlocal==5.2
    urllib3==1.26.20
    yarl==1.18.3
    

    Code Snippet:

    import azure.functions as func
    import logging
    from snowflake.snowpark.session import Session
    from snowflake.snowpark.functions import when_matched, when_not_matched,col
    
    app = func.FunctionApp()
    
    @app.route(route="http_trigger", auth_level=func.AuthLevel.ANONYMOUS)
    def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
        logging.info('Python HTTP trigger function processed a request.')
    
        name = req.params.get('name')
        if not name:
            try:
                req_body = req.get_json()
            except ValueError:
                pass
            else:
                name = req_body.get('name')
    
        if name:
            return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
        else:
            return func.HttpResponse(
                 "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
                 status_code=200
            )
    

    Deployed the function to Azure:

    Command: func azure functionapp publish rkfn
    
    Getting site publishing info...
    [2024-12-10T06:21:04.832Z] Starting the function app deployment...
    Removing WEBSITE_CONTENTAZUREFILECONNECTIONSTRING app setting.
    Removing WEBSITE_CONTENTSHARE app setting.
    Creating archive for current directory...
    Performing remote build for functions project.
    Uploading 114.44 MB [#############################################################################]
    Remote build in progress, please wait...
    Updating submodules.
    Preparing deployment for commit id '4c0c74d4-c'.
    //Removed few logs
    [06:25:18+0000] Installing collected packages: six, pycparser, urllib3, python-dateutil, jmespath, cffi, propcache, multidict, idna, frozenlist, cryptography, charset-normalizer, certifi, botocore, yarl, typing-extensions, tomlkit, soupsieve, sortedcontainers, s3transfer, requests, pytz, pyOpenSSL, PyJWT, platformdirs, packaging, orderedmultidict, greenlet, filelock, attrs, asn1crypto, aiosignal, aiohappyeyeballs, wheel, tzlocal, tzdata, SQLAlchemy, snowflake-connector-python, setuptools, scramp, PyYAML, protobuf, numpy, lxml, furl, cloudpickle, boto3, beautifulsoup4, azure-functions, aiohttp, snowflake-sqlalchemy, snowflake-snowpark-python, redshift-connector, pyodbc, pyarrow, pandas, azure-functions-durable, async-timeout
    [06:25:30+0000] Successfully installed PyJWT-2.10.1 PyYAML-6.0.2 SQLAlchemy-1.4.7 aiohappyeyeballs-2.4.4 aiohttp-3.11.10 aiosignal-1.3.1 asn1crypto-1.5.1 async-timeout-5.0.1 attrs-24.2.0 azure-functions-1.21.3 azure-functions-durable-1.2.10 beautifulsoup4-4.12.3 boto3-1.35.77 botocore-1.35.77 certifi-2024.8.30 cffi-1.17.1 charset-normalizer-3.4.0 cloudpickle-2.2.1 cryptography-44.0.0 filelock-3.16.1 frozenlist-1.5.0 furl-2.1.3 greenlet-3.1.1 idna-3.10 jmespath-1.0.1 lxml-5.3.0 multidict-6.1.0 numpy-1.25.2 orderedmultidict-1.0.1 packaging-24.2 pandas-2.0.3 platformdirs-4.3.6 propcache-0.2.1 protobuf-5.29.1 pyOpenSSL-24.3.0 pyarrow-18.1.0 pycparser-2.22 pyodbc-4.0.39 python-dateutil-2.9.0.post0 pytz-2024.2 redshift-connector-2.1.4 requests-2.32.3 s3transfer-0.10.4 scramp-1.4.5 setuptools-75.6.0 six-1.17.0 snowflake-connector-python-3.12.3 snowflake-snowpark-python-1.25.0 snowflake-sqlalchemy-1.5.1 sortedcontainers-2.4.0 soupsieve-2.6 tomlkit-0.13.2 typing-extensions-4.12.2 tzdata-2024.2 tzlocal-5.2 urllib3-1.26.20 wheel-0.45.1 yarl-1.18.3
    WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
    WARNING: You are using pip version 21.2.4; however, version 24.3.1 is available.
    You should consider upgrading via the '/tmp/oryx/platforms/python/3.11.10/bin/python3.11 -m pip install --upgrade pip' command.
    Not a vso image, so not writing build commands
    Preparing output...
    
    Copying files to destination directory '/home/site/wwwroot'...
    Done in 11 sec(s).
    //Removed few logs
    Remote build.
    Remote build succeeded!
    [2024-12-10T06:27:45.864Z] Syncing triggers...
    Functions in rkfn:
        http_trigger - [httpTrigger]
            Invoke url: https://XXXXfn.azurewebsites.net/api/http_trigger
    

    Portal:

    Able to see the function trigger in Azure function App in portal.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search