Share via

HTTP Trigger with Python 500 error after enabling import swagger_client as cris_client

Tigran 96 Reputation points
2021-07-12T16:19:02.377+00:00

Hello Everyone ,
As soon as we add import swagger_client as cris_client to the init.py code and we deploy it function give 500 error . If comment that line out then it works. We do need to use swagger client library that we imported to do speech to text project.

In case it useful we used this guide to create it .
https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/python/from-blob .
Any help would appreciate here is our requriments.txt context and here is the sample code.

DO NOT include azure-functions-worker in this file

The Python Worker is managed by Azure Functions platform

Manually managing azure-functions-worker may cause unexpected issues

azure-functions==1.7.2
azure-cognitiveservices-speech==1.17.0

logging

sys

requests==2.25.1

json,os,time

swagger-ui-py==0.3.0

grpcio==1.33.1

grpcio-tools==1.33.1

protobuf==3.17.3
python-dateutil==2.8.1
six==1.16.0
certifi==2021.5.30
python_dateutil==2.8.1

setuptools == 21.0.0

urllib3==1.26.6


import logging
import azure.functions as func
import sys
import requests,json,os
import time
import swagger_client as cris_client

from transcribe_code import * #getting issue here when enabled when deployed

def main(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')
        RECORDINGS_BLOB_URI = req_body.get('name')

if name:
    #json_result=transcribe(RECORDINGS_BLOB_URI)
    #return func.HttpResponse({json_result})
    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
    )
Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

Answer accepted by question author

Tigran 96 Reputation points
2021-07-13T18:11:57.61+00:00

Thanks. i was able to fix the issues by providing package path to swagger instead of providing name of the package in the requirments.txt. Thanks again

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. MayankBargali-MSFT 71,016 Reputation points Moderator
    2021-07-13T06:42:04.96+00:00

    @Tigran Can you navigate to your application insights logs for your function app and verify what exception is logged for the 500 error. It looks like module not found.
    Can you confirm which module you are referring as swagger_client or cris_client as I don't see as pypi packages. If the modules can be installed using pip then you can mentioned the same in your requirements.txt
    But in case if those module or dependencies cannot be installed using pip then you need to use build native dependencies or enable remote build.
    You can refer to python troubleshooting document for more details.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.