Azure / Azure/azure-functions-python-worker

Azure function python v2 with external packages HTTP Trigger not visible in Azure Portal after deployment

Abierto
#1,262 117 comentarios 21 reacciones 2 asignados Reclamado por @shreyabatra4 Ver en GitHub
needs-attention :wave:
Lenguaje dominante
Python
Estrellas
357
Forks
116
Merge medio
32 min
PR fusionados (30 d)
1

Descripción

Refer this SO Thread and my answer - https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#> The Azure python Function with V2 programming model including external packages and imports in function_app.py works locally, But when I deploy it in Azure the Function Trigger is not visible. If I deploy default HTTP Trigger with python v2 programming model, The trigger is visible after deployment. But not when i add custom imports in the function_app.py and requirements.txt. Refer this image - https://i.imgur.com/CjCnsY8.png but the function files are visible in app files like here- https://i.imgur.com/R3SZWcW.png . I tried the deployment with App service plan and consumption plan both, Still no luck. I also added AzureWebJobsFeatureFlags:EnableWorkerIndexing settings, I also tried to deploy this function as zip using azure cli zip command with required settings to deploy function as zip, I also tried to deploy it with function core tools func azure functionapp publish command and also via VS code still no luck.
### Investigative information
###### Please provide the following:

- Timestamp:
- Function App name: siliconfunc311
- Function name(s) (as appropriate): Http trigger pythonv2
- Core Tools version:4.0.5148

### Repro steps
###### Provide the steps required to reproduce the problem:

Refer this SO thread and my answer- https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#comment134830419_76463210

### Expected behavior
###### Provide a description of the expected behavior.

after deployment HTTP trigger should be visible in Azure portal

### Actual behavior
###### Provide a description of the actual behavior observed.

Function trigger is not visible in Functions section of Function tab but files are visible in app files

### Known workarounds
###### Provide a description of any known workarounds.

### Contents of the requirements.txt file:
###### Provide the requirements.txt file to help us find out module related issues.

numpy

pandas

opencv-python-headless

librosa

torch

torchaudio

torch-audiomentations

torchvision

azure-functions

### Related information
###### Provide any related information

* Links to source

https://stackoverflow.com/questions/76458717/why-is-the-functions-runtime-not-finding-my-functions-when-i-import-certain-pack/76463210?noredirect=1#comment134830419_76463210

```python
# function_app.py

import logging
import azure.functions as func
import numpy as np
import pandas as pd
import cv2
import librosa
import torch
import torchaudio
import torch_audiomentations
import torchvision
from azure.functions import HttpRequest

app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)

@app.route(route="HttpTrigger")
def HttpTrigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

#code block with imported packages
arr = np.array([1, 2, 3])
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
image = cv2.imread('Screenshot (1).png')
audio_data, sample_rate = librosa.load('sample.wav.mp3')
tensor = torch.tensor([1, 2, 3])
transformed_tensor = torch_audiomentations.PitchShift(sample_rate=sample_rate, p=1.0)
torchvision.transforms.ToTensor()(image)

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
)
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.