Azure Log Ingestion API返回204但无数据的Azure端排查方法
问题:Azure Log Ingestion API返回204但无数据写入自定义表
我开发了一个Python脚本,通过Azure Log Ingestion API将JSON格式的日志上传至自定义表。该脚本曾成功运行两次,数据能正常显示,但如今每次运行均返回<Response [204]>响应,自定义表却无新数据生成。
已尝试的操作
- 遵循微软官方文档,尝试两种Python上传方式:
- 带相关参数的原生
request.post命令 - 文档Python示例中的
client.upload命令
- 带相关参数的原生
- Python调试显示数据格式无误,响应状态正常,但因需脱敏无法提供更多细节。
其中一种Python请求代码如下:
logCombined = <JSON data array> payload = json.dumps(logCombined) applicationId scope = "https://monitor.azure.com//.default" appSecret = <application (client) secret> tenantId = <tenant ID> dceUri= <dedicated endpoint URI> dcrImmutableId = <DCR immutable ID> table= "MyTable_CL" body = f"client_id={applicationId}&scope={scope}&client_secret={appSecret}&grant_type=client_credentials" headers = {"Content-Type": "application/x-www-form-urlencoded"} uri = f"https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token" response = req.post(uri, data=body, headers=headers) # 获取Bearer Token bearerToken = respons.json().get("access_token") # 注:此处存在笔误,应为response headers2 = { "Authorization": f"Bearer {bearerToken}", "Content-Type": "application/json" } uri = f"{dceUri}/dataCollectionRules/{dcrImmutableId}/streams/Custom-{table}?api-version=2021-11-01-preview" uploadResponse = req.post(uri, data=payload, headers=headers2) print("Response: ", uploadResponse)
目前Azure侧无任何操作日志记录,也无新数据生成,请问在Azure端可执行哪些排查步骤来定位问题?
内容的提问来源于stack exchange,提问作者Daniel K
相关产品推荐
相关产品推荐

