Azure WebPub 二头肌文档没有提及如何启用诊断设置以将日志流式传输到日志分析工作区,但 Azure 门户有一个界面。
我猜我必须创建一个 Microsoft.Insights/diagnosticSettings 资源,购买同样的东西也适用于这里。没有明显的文档。
如何为 Azure Web PubSub 启用二头肌诊断?
感谢您让我走向正确的方向@Thomas。您的类别名称有点不对劲,我还需要属性中的workspaceId。经过多次尝试,我通过简单地将手动配置导出到 ARM 来获取类别名称,并发现名称应如下所示。
resource webPubSubDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: '${webPubSubName}-DiagnosticSettings'
scope: webpubsub
properties: {
workspaceId: logAnalyticsWorkspace.id
logs: [
{
category: 'ConnectivityLogs'
enabled: true
}
{
category: 'MessagingLogs'
enabled: true
}
{
category: 'HttpRequestLogs'
enabled: true
}
]
metrics: [
{
enabled: true
category: 'AllMetrics'
}
]
}
}
类似的东西应该有效:
param webPubSubName string
// Get a reference to the existing signalR service
resource signalR 'Microsoft.SignalRService/webPubSub@2021-10-01' existing = {
name:webPubSubName
}
// Get the log category to send
// See https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/tables-resourcetype?source=recommendations#signalr-service-webpubsub
var logTypes = [
'AzureActivity'
'WebPubSubConnectivity'
'WebPubSubHttpRequest'
'WebPubSubMessaging'
]
// Send logs to azure monitor
resource webPubSubLogs 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
scope: signalR
name: signalR.name
properties: {
...
logs: [for logType in logTypes: {
category: logType
enabled: true
retentionPolicy: {
enabled: true
days: 0
}
}]
metrics: [
{
category: 'AllMetrics'
enabled: true
retentionPolicy: {
enabled: true
days: 0
}
}
]
}
}