Код: Выделить всё
func init --worker-runtime python --docker
func new --name HttpExample --template "HTTP trigger"
Код: Выделить всё
FROM mcr.microsoft.com/azure-functions/python:4-python3.10
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY . /home/site/wwwroot
Но после этого я использовал другое приложение, использующее функцию Azure, где Я импортировал различные библиотеки. Это приложение работает нормально локально, используя func start, но оно не работает внутри образа Docker.
На http://localhost:8080/api/HttpExample я получил ошибку, что веб-страница не найдена, и в console Я получил предупреждение о том, что функции задания не найдены.
Это код, который я использовал:
Код: Выделить всё
import azure.functions as func
import datetime
import json
import logging
from model import predict
app = func.FunctionApp()
@app.route(route="HttpExample", auth_level=func.AuthLevel.ANONYMOUS)
def HttpExample(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:
name=predict(name)
return func.HttpResponse(f"{name}")
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
)
Это мой файл требований.txt:
Код: Выделить всё
azure-core
azure-functions
azure-identity
llama-index
llama-index-embeddings-azure-openai
llama-index-llms-azure-openai
llama-index-readers-file
llama-index-vector-stores-chroma
pypdf
Подробнее здесь: https://stackoverflow.com/questions/786 ... ide-docker