Azure / Azure/azure-functions-python-library

[BUG] Service Bus Session ID is not available to Function code

未关闭
#103 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug needs-investigation
主要语言
Python
星标
179
派生
79
平均合并
2 天 8 小时
30 天内合并 PR
2

描述

### Investigative information
###### Please provide the following:
IcM: 283549053 has an impacted function app with relevant detail

### Repro steps
1. Create a Function App that triggers off a Service bus session enabled queue.
###### Provide the steps required to reproduce the problem:

### Expected behavior
###### Provide a description of the expected behavior.

### Actual behavior
###### Provide a description of the actual behavior observed.

### Known workarounds
###### Provide a description of any known workarounds.
Fetch the session id from the nested field in the message:
msg.metadata["MessageSession"]["SessionId"]

### Contents of the requirements.txt file:
###### Provide the requirements.txt file to help us find out module related issues.
N/A

### Related information
###### Provide any related information

* Bindings used: Service Bus

```python
def main(msg: func.ServiceBusMessage):
logging.info('Python ServiceBus queue trigger processed message: %s',
msg.get_body().decode('utf-8'))
logging.info('Python msg.session_id - : %s', msg.metadata["MessageSession"]["SessionId"])
logging.info('Python msg.session_id1 - : %s', msg.session_id)
```

Output
```logs
[2022-02-09T00:36:58.242Z] Python msg.session_id - : {12229E1-B37B-4D29-AA0A-E367906C206E}
[2022-02-09T00:36:58.242Z] Python msg.session_id1 - : None
```

The [location where library sets session_id](https://github.com/Azure/azure-functions-python-library/blob/dev/azure/functions/servicebus.py#L274-L275).

```bash
curl -H "Authorization: SharedAccessSignature sr=SERVICE_BUS.servicebus.windows.net%2FINPUT_QUEUE&sig=XXXXXX&se=YYY&skn=RootManageSharedAccessKey" \
-H 'BrokerProperties: {"SessionId": "{12229E1-B37B-4D29-AA0A-E367906C206E}"}' \
-H "Content-Type: application/json" \
-d "HelloWorld" \
-X POST -i "https://servicebus-test-vameru.servicebus.windows.net/myinputqueue/messages\?timeout\=60"

HTTP/1.1 201 Created
Transfer-Encoding: chunked
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000
Date: Wed, 09 Feb 2022 00:36:57 GMT
```

The Complete Metadata
```json
{
"UserProperties": {},
"DeliveryCount": 1,
"LockToken": "fc949e24-410f-4a78-853b-7b8ce125cb99",
"MessageSession": {
"LockedUntilUtc": "2022-02-08T22: 30: 52.33697Z",
"SessionId": "{17729E1-B37B-4D29-AA0A-E367906C206E}",
"RegisteredPlugins": [],
"ReceiveMode": 0,
"PrefetchCount": 0,
"LastPeekedSequenceNumber": 0,
"Path": "myinputqueue",
"OperationTimeout": "00: 01: 00",
"ServiceBusConnection": {
"Endpoint": "sb://servicebus-test-vameru.servicebus.windows.net",
"OperationTimeout": "00:01:00",
"RetryPolicy": {
"MinimalBackoff": "00:00:00",
"MaximumBackoff": "00:00:30",
"DeltaBackoff": "00:00:03",
"MaxRetryCount": 5,
"IsServerBusy": False,
"ServerBusyExceptionMessage": None
},
"TransportType": 0,
"TokenProvider": {},
"IsClosedOrClosing": False
},
"IsClosedOrClosing": False,
"OwnsConnection": False,
"ClientId": "MessageSession27myinputqueue_{17729E1-B37B-4D29-AA0A-E367906C206E}",
"RetryPolicy": {
"MinimalBackoff": "00:00:00",
"MaximumBackoff": "00:00:30",
"DeltaBackoff": "00:00:03",
"MaxRetryCount": 5,
"IsServerBusy": False,
"ServerBusyExceptionMessage": None
}
},
"ContentType": "application/json",
"SequenceNumber": 13,
"MessageReceiver": {
"LockedUntilUtc": "2022-02-08T22:30:52.33697Z",
"SessionId": "{17729E1-B37B-4D29-AA0A-E367906C206E}",
"RegisteredPlugins": [],
"ReceiveMode": 0,
"PrefetchCount": 0,
"LastPeekedSequenceNumber": 0,
"Path": "myinputqueue",
"OperationTimeout": "00:01:00",
"ServiceBusConnection": {
"Endpoint": "sb://servicebus-test-vameru.servicebus.windows.net",
"OperationTimeout": "00:01:00",
"RetryPolicy": {
"MinimalBackoff": "00:00:00",
"MaximumBackoff": "00:00:30",
"DeltaBackoff": "00:00:03",
"MaxRetryCount": 5,
"IsServerBusy": False,
"ServerBusyExceptionMessage": None
},
"TransportType": 0,
"TokenProvider": {},
"IsClosedOrClosing": False
},
"IsClosedOrClosing": False,
"OwnsConnection": False,
"ClientId": "MessageSession27myinputqueue_{17729E1-B37B-4D29-AA0A-E367906C206E}",
"RetryPolicy": {
"MinimalBackoff": "00:00:00",
"MaximumBackoff": "00:00:30",
"DeltaBackoff": "00:00:03",
"MaxRetryCount": 5,
"IsServerBusy": False,
"ServerBusyExceptionMessage": None
}
},
"EnqueuedTimeUtc": "2022-02-08T22:22:19.292Z",
"ExpiresAtUtc": "2022-02-22T22:22:19.292Z",
"MessageId": "806c77a2924441fe855697d39647e096"
}
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

先阅读 azure/functions/servicebus.py 第274-275行附近的内容,并比较启用会话的消息如何通过嵌套元数据 workaround 填充 msg.session_id。重现 Service Bus 会话队列示例,然后验证 msg.session_id 会公开 SessionId,同时保持现有的消息元数据行为不变。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, python
领域
backend, distributed-systems
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。