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