Azure Python V2 FunctionApp deployed successfully but triggers not found

Djordje Djukic 0 Reputation points
2024-10-01T01:16:14.1+00:00

Hello there,

so I have a python v2 functionApp created in VS Code (func init) with service bus topic trigger , all necessary stuff is there. local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "ServiceBusConnectionString": "****"
  }
}

requirements.txt:

azure-functions
openai
langdetect
azure-identity
azure-keyvault-secrets
psycopg2

and most importantly function_app.py: save_to_db(record_to_save, record_type="truefalse")

import azure.functions as func
import os
from openai import OpenAI
import logging
from langdetect import detect
import datetime
import json
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
import logging
import psycopg2
import uuid

# Postavljanje OpenAI API ključa iz varijabli okruženja
key_vault_url = "https://rewizzy-keyvault.vault.azure.net/"

credential = DefaultAzureCredential()
secret_client = SecretClient(vault_url=key_vault_url, credential=credential)

API_KEY = secret_client.get_secret("gpt-api-key").value
SBUS_CONN_STR = secret_client.get_secret("sbus-conn-string").value
DB_USER = secret_client.get_secret("db-user").value
DB_PASS = secret_client.get_secret("db-pass").value
DB_HOST = secret_client.get_secret("db-host").value
logging.info(f"Type of the db_host: {type(DB_HOST)}")

client = OpenAI(
    # This is the default and can be omitted
    api_key=API_KEY,
)
app = func.FunctionApp()

## SOME HELPER FUNCITONS 

@app.function_name('generate-essay-question')
@app.service_bus_topic_trigger(arg_name="azservicebus", subscription_name="subscription1", topic_name="mychunktopic",
                               connection="ServiceBusConnectionString") 
async def generate_essay_q(azservicebus: func.ServiceBusMessage):
    message_body = azservicebus.get_body().decode('utf-8')
    logging.info(f"Processing essay question for message.")
    
    essay_question = await generate_essay_question(message_body)
    logging.info(f"Generated essay question")

@app.function_name('generate-quiz-question')
@app.service_bus_topic_trigger(arg_name="azservicebus", subscription_name="subscription2", topic_name="mychunktopic",
                               connection="ServiceBusConnectionString") 
async def generate_mchoice_q(azservicebus: func.ServiceBusMessage):
    message_body = azservicebus.get_body().decode('utf-8')
    logging.info(f"Processing quiz for message.")
    
    essay_question = await generate_mchoice_question(message_body)
    logging.info(f"Generated quiz question")

@app.function_name('generate-true-false-question')
@app.service_bus_topic_trigger(arg_name="azservicebus", subscription_name="subscription3", topic_name="mychunktopic",
                               connection="ServiceBusConnectionString") 
async def generate_true_false_q(azservicebus: func.ServiceBusMessage):
    message_body = azservicebus.get_body().decode('utf-8')
    logging.info(f"Processing essay question for message")
    
    essay_question = await generate_true_false_question(message_body)
    logging.info(f"Generated true/false question.")

The main problem is that when I deploy the Functions, they don't appear on the portal, even though the deployment was successful. I am really desperate, as I have been struggling with this issue for 5 days. There are no logs, no errors, but the deployment isn't working.

I've tried literally everything. Python version, application settings, but no luck. Please help

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
625 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,002 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 4,295 Reputation points Microsoft Employee
    2024-10-04T11:35:24.9766667+00:00

    Hello @Djordje Djukic

    First, can you confirm that you have published your FunctionApp to Azure? You can do this by running the following command in the terminal: func azure functionapp publish If you have already published your FunctionApp, can you check if the triggers are showing up in the Azure portal?

    You can do this by navigating to your FunctionApp in the portal, clicking on "Functions" in the left-hand menu, and checking if your triggers are listed there.

    If your triggers are not showing up in the portal, it's possible that there was an issue with the deployment. Can you check the deployment logs to see if there were any errors or warnings during the deployment process?

    You can do this by running the following command in the terminal: func azure functionapp logstream

    This will stream the logs from your FunctionApp to the terminal. You can also view the logs in the Azure portal by navigating to your FunctionApp, clicking on "Functions" in the left-hand menu, and then clicking on "Logs" in the top menu. That should solve your query.

    0 comments No comments

Your answer

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