-
Notifications
You must be signed in to change notification settings - Fork 626
Expand file tree
/
Copy pathfunction_app.py
More file actions
52 lines (44 loc) · 2.02 KB
/
function_app.py
File metadata and controls
52 lines (44 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import logging
import os
import azure.functions as func
from add_url_embeddings import bp_add_url_embeddings
from batch_push_results import bp_batch_push_results
from batch_start_processing import bp_batch_start_processing
from get_conversation_response import bp_get_conversation_response
from combine_pages_chunknos import bp_combine_pages_and_chunknos
from azure.monitor.opentelemetry import configure_azure_monitor
logging.captureWarnings(True)
# Logging configuration from environment variables
AZURE_BASIC_LOGGING_LEVEL = os.environ.get("LOGLEVEL", "INFO")
PACKAGE_LOGGING_LEVEL = os.environ.get("PACKAGE_LOGGING_LEVEL", "WARNING")
AZURE_LOGGING_PACKAGES = os.environ.get("AZURE_LOGGING_PACKAGES", "")
AZURE_LOGGING_PACKAGES = [pkg.strip() for pkg in AZURE_LOGGING_PACKAGES if pkg.strip()]
# Configure logging levels from environment variables
logging.basicConfig(
level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO)
)
# Configure Azure package logging levels
azure_package_log_level = getattr(
logging, PACKAGE_LOGGING_LEVEL.upper(), logging.WARNING
)
for logger_name in AZURE_LOGGING_PACKAGES:
logging.getLogger(logger_name).setLevel(azure_package_log_level)
if os.getenv("APPLICATIONINSIGHTS_ENABLED", "false").lower() == "true":
configure_azure_monitor()
# Suppress noisy Azure SDK loggers AFTER configure_azure_monitor()
# to prevent it from overriding our levels
_NOISY_AZURE_LOGGERS = [
"azure.core.pipeline.policies.http_logging_policy",
"azure.monitor.opentelemetry.exporter",
"azure.identity",
]
for logger_name in _NOISY_AZURE_LOGGERS:
logging.getLogger(logger_name).setLevel(logging.WARNING)
app = func.FunctionApp(
http_auth_level=func.AuthLevel.FUNCTION
) # change to ANONYMOUS for local debugging
app.register_functions(bp_add_url_embeddings)
app.register_functions(bp_batch_push_results)
app.register_functions(bp_batch_start_processing)
app.register_functions(bp_get_conversation_response)
app.register_functions(bp_combine_pages_and_chunknos)