Все функции исчезают, как только я добавляю eventHubTrigger?Python

Программы на Python
Anonymous
Все функции исчезают, как только я добавляю eventHubTrigger?

Сообщение Anonymous »

Я занимаюсь кое-чем в Azure. Я могу без проблем добавить httpTrigger по умолчанию, но как только я добавляю eventHubTrigger, все мои функции (даже httpTrigger) просто исчезают. Как будто на самом деле функций больше нет. Это произошло в двух разных приложениях-функциях.
Я использую план гибкого потребления с Azure для студентов. Действия Github могут его развернуть, но Azure отказывается принимать его как Python. Он получает файлы, но отказывается их использовать/видит в них реальные функции. Структура файлов/папок не изменилась, ничего из файлов по умолчанию не изменилось, файл require.txt обновлен...
Я старался изо всех сил, пробовал 3 разных AI, и мои возможности на исходе.
Код: (function_app.py)
import azure.functions as func
import logging
import json
import os
import uuid
from azure.cosmos import CosmosClient

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

@app.route(route="http_trigger")
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
)

@app.event_hub_message_trigger(
arg_name="azeventhub",
event_hub_name="iothub-ehub-applied-io-55753535-0fd7cb3e46",
connection="IOTHUB"
)
def eventhub_trigger1(azeventhub: func.EventHubEvent):
logging.info('Python EventHub trigger processed an event.')

# Initialize Cosmos inside the function so it only runs when triggered
cosmos_client = CosmosClient(
os.getenv("COSMOS_URL"),
credential=os.getenv("COSMOS_KEY")
)
container = cosmos_client \
.get_database_client(os.getenv("COSMOS_DB_NAME")) \
.get_container_client(os.getenv("COSMOS_CONTAINER_NAME"))

try:
# 1. Decode message
body = azeventhub.get_body().decode('utf-8')
logging.info(f"Raw message: {body}")

data = json.loads(body)

# 2. Check if OPCUA data exists
if "OPCUA" in data:
opcua_data = data["OPCUA"]

# 3. Prepare item for Cosmos DB
item = {
"id": str(uuid.uuid4()),
"type": "OPCUA",
**opcua_data
}

# 4. Insert into Cosmos DB
container.create_item(body=item)
logging.info(f"Inserted OPCUA data: {item}")

else:
logging.warning("Message is not OPCUA, skipping")

except Exception as e:
logging.error(f"Error processing event: {e}")

----- ЖУРНАЛЫ AZURE: -----
2026-05-05T12:12:12 [Information] Executing StatusCodeResult, setting HTTP status code 200
2026-05-05T12:12:33 [Verbose] Ping Status: {
"hostState": "Running"
}
2026-05-05T12:12:33 [Information] Executing StatusCodeResult, setting HTTP status code 200
2026-05-05T12:12:34 [Verbose] AuthenticationScheme: WebJobsAuthLevel was not authenticated.
2026-05-05T12:12:34 [Verbose] Authorization was successful.
2026-05-05T12:12:34 [Verbose] Received request to drain the host
2026-05-05T12:12:34 [Information] DrainMode mode enabled
2026-05-05T12:12:34 [Information] Calling StopAsync on the registered listeners
2026-05-05T12:12:34 [Information] Call to StopAsync complete, registered listeners are now stopped
2026-05-05T12:12:34 [Verbose] AuthenticationScheme: WebJobsAuthLevel was not authenticated.
2026-05-05T12:12:34 [Verbose] Authorization was successful.
2026-05-05T12:12:34 [Verbose] Received request to drain the host
2026-05-05T12:12:34 [Information] DrainMode mode enabled
2026-05-05T12:12:34 [Information] Calling StopAsync on the registered listeners
2026-05-05T12:12:34 [Information] Call to StopAsync complete, registered listeners are now stopped
2026-05-05T12:12:38 [Verbose] Ping Status: {
"hostState": "Running"
}
2026-05-05T12:12:38 [Information] Executing StatusCodeResult, setting HTTP status code 200
2026-05-05T12:12:40 [Verbose] AuthenticationScheme: WebJobsAuthLevel was not authenticated.
2026-05-05T12:12:40 [Verbose] Authorization was successful.
2026-05-05T12:12:40 [Verbose] Drain Status: 2, Activity Status: {
"OutstandingInvocations": 0,
"OutstandingRetries": 0
}
2026-05-05T12:12:40 [Verbose] AuthenticationScheme: WebJobsAuthLevel was not authenticated.
2026-05-05T12:12:40 [Verbose] Authorization was successful.
2026-05-05T12:12:40 [Verbose] Drain Status: 2, Activity Status: {
"OutstandingInvocations": 0,
"OutstandingRetries": 0
}
2026-05-05T12:12:42 [Verbose] Ping Status: {
"hostState": "Running"
}
2026-05-05T12:12:42 [Information] Executing StatusCodeResult, setting HTTP status code 200
2026-05-05T12:13:03 [Verbose] Ping Status: {
"hostState": "Running"

Вернуться в «Python»