MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.01k stars 21k forks source link

Azure Function in python - V2 model - using service_bus_topic_trigger - not documented how to receive only concrete SessionId #122239

Open alfrepo opened 1 week ago

alfrepo commented 1 week ago

Python Azure Function

In a Azure Function, written in Python using V2 model, as generated by Visual Studio Code

It is not documented how to set the SESSION_ID.

How do I receive only topic messages with a preset SessionId?

import logging
import azure.functions as func
import os

app = func.FunctionApp()

TOPIC_NAME_A = os.environ['Topic']
#CONN_STRING = os.environ['ServiceBusConnection']
SESSION_ID = os.environ['SessionId']

@app.service_bus_topic_trigger(arg_name="azservicebus", 
                               topic_name=TOPIC_NAME_A,
                               subscription_name="alfdevapi6subscription",
                               connection="ServiceBusConnection") 
def servicebus_trigger(azservicebus: func.ServiceBusMessage):
    logging.warn('Python ServiceBus Queue trigger processed a message: %s',
                azservicebus.get_body().decode('utf-8'))

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

TPavanBalaji commented 1 week ago

@alfrepo It would be great if you could add a link to the documentation you are following for these steps? This would help us redirect the issue to the appropriate team. Thanks!

alfrepo commented 1 week ago

I followed this docu https://learn.microsoft.com/de-de/azure/azure-functions/functions-develop-vs-code?tabs=node-v4%2Cpython-v2%2Cisolated-process&pivots=programming-language-python

And have generated an azure function in python, which listens to topics, but doesn't have access to session Id.

TPavanBalaji commented 1 week ago

@alfrepo Thanks for your feedback! We will investigate and update as appropriate.