[Python] How to authenticate a user when reporting a custom_event using python in appinsight

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to trigger a custom event in a python application to record a system action linked to a specific user.

    Our front end application provides a user_Id and user_AuthenticatedId to app insight and I want to populate the later at least in the backend side somewhere (I don't have access to the operations etc, only the UserId)

    The only code I got functioning do trigger the custom event

    from azure.monitor.opentelemetry import configure_azure_monitor
    from azure.monitor.events.extension import track_event

    configure_azure_monitor(
    disable_offline_storage=True,
    logger_name="telemetry"
    )

    def my_actual_function():
    ...
    track_event(
    "test-custom-event",
    {
    "user_AuthenticatedId": "toto",
    "user_Id": "1111000003333",
    "data": json.dumps({"test": 'OK'}),
    }
    )
    ...


    but there is no linked user in app insight, in the first line corresponding to my "test-custom-event" the user columns are empty [​IMG]

    Continue reading...

Compartilhe esta Página