Skip to content

Commit 2519fca

Browse files
committed
Add aujtentcation for logging
1 parent 37fc5f9 commit 2519fca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

code/function/fastapp/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
from logging import Logger
33

4+
from azure.identity import DefaultAzureCredential
45
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
56
from fastapi import FastAPI
67
from fastapp.core.config import settings
@@ -35,8 +36,10 @@ def setup_tracer(app: FastAPI):
3536
RETURNS (None): Nothing is being returned.
3637
"""
3738
if settings.APPLICATIONINSIGHTS_CONNECTION_STRING:
39+
credential = DefaultAzureCredential()
3840
exporter = AzureMonitorTraceExporter.from_connection_string(
39-
settings.APPLICATIONINSIGHTS_CONNECTION_STRING
41+
settings.APPLICATIONINSIGHTS_CONNECTION_STRING,
42+
credential=credential
4043
)
4144
tracer = TracerProvider(resource=Resource({SERVICE_NAME: "api"}))
4245
tracer.add_span_processor(BatchSpanProcessor(exporter))

0 commit comments

Comments
 (0)