Microsoft.ApiManagement 服務/apis/診斷 2024-10-01-preview

Bicep 資源定義

服務/apis/診斷資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。

使用範例

Bicep 範例

部署 API 管理 服務 API 診斷記錄的基本範例。

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource component 'Microsoft.Insights/components@2020-02-02' = {
  name: resourceName
  location: location
  kind: 'web'
  properties: {
    Application_Type: 'web'
    DisableIpMasking: false
    DisableLocalAuth: false
    ForceCustomerStorageForProfiler: false
    RetentionInDays: 90
    SamplingPercentage: 100
    publicNetworkAccessForIngestion: 'Enabled'
    publicNetworkAccessForQuery: 'Enabled'
  }
}

resource service 'Microsoft.ApiManagement/service@2021-08-01' = {
  name: resourceName
  location: location
  sku: {
    capacity: 0
    name: 'Consumption'
  }
  properties: {
    certificates: []
    customProperties: {
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11': 'false'
    }
    disableGateway: false
    publicNetworkAccess: 'Enabled'
    publisherEmail: 'pub1@email.com'
    publisherName: 'pub1'
    virtualNetworkType: 'None'
  }
}

resource api 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
  name: '${resourceName};rev=1'
  parent: service
  properties: {
    apiType: 'http'
    apiVersion: ''
    format: 'swagger-link-json'
    path: 'test'
    type: 'http'
    value: 'http://conferenceapi.azurewebsites.net/?format=json'
  }
}

resource logger 'Microsoft.ApiManagement/service/loggers@2021-08-01' = {
  name: resourceName
  parent: service
  properties: {
    credentials: {
      instrumentationKey: component.properties.InstrumentationKey
    }
    description: ''
    isBuffered: true
    loggerType: 'applicationInsights'
  }
}

resource diagnostic 'Microsoft.ApiManagement/service/apis/diagnostics@2021-08-01' = {
  name: 'applicationinsights'
  parent: api
  properties: {
    loggerId: logger.id
    operationNameFormat: 'Name'
  }
}

Azure 已驗證的模組

下列 Azure 驗證模組 可用來部署此資源類型。

Module Description
API 管理服務 - API 診斷 API 管理服務的 AVM 子模組 - API 診斷

資源格式

若要建立 Microsoft.ApiManagement/service/apis/diagnostics 資源,請將下列 Bicep 新增至範本。

resource symbolicname 'Microsoft.ApiManagement/service/apis/diagnostics@2024-10-01-preview' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    alwaysLog: 'string'
    backend: {
      request: {
        body: {
          bytes: int
        }
        dataMasking: {
          headers: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
          queryParams: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
        }
        headers: [
          'string'
        ]
      }
      response: {
        body: {
          bytes: int
        }
        dataMasking: {
          headers: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
          queryParams: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
        }
        headers: [
          'string'
        ]
      }
    }
    frontend: {
      request: {
        body: {
          bytes: int
        }
        dataMasking: {
          headers: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
          queryParams: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
        }
        headers: [
          'string'
        ]
      }
      response: {
        body: {
          bytes: int
        }
        dataMasking: {
          headers: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
          queryParams: [
            {
              mode: 'string'
              value: 'string'
            }
          ]
        }
        headers: [
          'string'
        ]
      }
    }
    httpCorrelationProtocol: 'string'
    largeLanguageModel: {
      logs: 'string'
      requests: {
        maxSizeInBytes: int
        messages: 'string'
      }
      responses: {
        maxSizeInBytes: int
        messages: 'string'
      }
    }
    logClientIp: bool
    loggerId: 'string'
    metrics: bool
    operationNameFormat: 'string'
    sampling: {
      percentage: int
      samplingType: 'string'
    }
    verbosity: 'string'
  }
}

屬性值

Microsoft.ApiManagement/service/apis/diagnostics

名稱 Description 價值觀
名稱 資源名稱 string

約束:
最小長度 = 1
最大長度 = 80
模式 = ^[^*#&+:<>?]+$ (必要)
父代 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。

如需詳細資訊,請參閱 父資源外部的子資源。
類型的資源符號名稱:service/apis
properties 診斷實體合約屬性。 DiagnosticContractProperties

BodyDiagnosticSettings (身體診斷設置)

名稱 Description 價值觀
bytes 要記錄的要求本文字節數目。 int

約束:
最大值 = 8192

資料遮罩

名稱 Description 價值觀
headers 標頭的遮罩設定 DataMaskingEntity[]
queryParams Url 查詢參數的遮罩設定 DataMaskingEntity[]

DataMaskingEntity

名稱 Description 價值觀
mode 資料遮罩模式。 “隱藏”
“面具”
value 要遮罩的實體名稱(例如標頭或查詢參數的名稱)。 字串

DiagnosticContractProperties

名稱 Description 價值觀
alwaysLog 指定不應該套用何種類型的訊息取樣設定。 'allErrors'
後端 傳入/傳出 HTTP 訊息至後端的診斷設定 PipelineDiagnosticSettings
frontend 傳入/傳出 HTTP 訊息至閘道的診斷設定。 PipelineDiagnosticSettings
HTTPCorrelationProtocol 協定 設定要用於Application Insights診斷的相互關聯通訊協定。 “遺產”
'None'
'W3C'
largeLanguageModel 大型語言模型診斷設定 LLMDiagnosticSettings
logClientIp 記錄 ClientIP。 預設值為 false。 布爾 (bool)
loggerId (記錄器識別) 目標記錄器的資源識別碼。 字串 (必要)
計量 透過 emit-metric 原則發出自訂指標。 僅適用於 Application Insights 診斷設定。 布爾 (bool)
操作名稱格式 Application Insights 遙測的作業名稱格式。 預設值為名稱。 “名字”
'Url'
取樣 診斷的取樣設定。 採樣設置
詳細程度 套用至追蹤原則所發出之追蹤的詳細資訊層級。 '錯誤'
'資訊'
'冗長'

HttpMessageDiagnostic

名稱 Description 價值觀
body 本文記錄設定。 BodyDiagnosticSettings (身體診斷設置)
資料遮罩 資料遮罩設定。 資料遮罩
headers 要記錄的 HTTP 標頭陣列。 字串[]

LLMDiagnosticSettings

名稱 Description 價值觀
記錄 指定是否應該為大型語言模型啟用預設診斷。 '已禁用'
'已啟用'
要求 大型語言模型要求的診斷設定。 LLMMessageDiagnosticSettings
回應 大型語言模型回應的診斷設定。 LLMMessageDiagnosticSettings

LLMMessageDiagnosticSettings

名稱 Description 價值觀
maxSizeInBytes 記錄的訊息大小上限(以位元組為單位)。 預設大小為 32KB。 int

約束:
最小值 = 1
最大值 = 262144
messages 指定應該記錄的訊息。 目前只有「全部」選項。 “全部”

PipelineDiagnosticSettings

名稱 Description 價值觀
要求 要求的診斷設定。 HttpMessageDiagnostic
response 回應的診斷設定。 HttpMessageDiagnostic

採樣設置

名稱 Description 價值觀
百分比 固定速率取樣的取樣率。 int

約束:
最小值 = 0
最大值 = 100
採樣類型 取樣類型。 '固定'

ARM 樣本資源定義

服務/apis/診斷資源類型可以使用目標作業來部署:

使用範例

資源格式

若要建立 Microsoft.ApiManagement/service/apis/diagnostics 資源,請將下列 JSON 新增至您的範本。

{
  "type": "Microsoft.ApiManagement/service/apis/diagnostics",
  "apiVersion": "2024-10-01-preview",
  "name": "string",
  "properties": {
    "alwaysLog": "string",
    "backend": {
      "request": {
        "body": {
          "bytes": "int"
        },
        "dataMasking": {
          "headers": [
            {
              "mode": "string",
              "value": "string"
            }
          ],
          "queryParams": [
            {
              "mode": "string",
              "value": "string"
            }
          ]
        },
        "headers": [ "string" ]
      },
      "response": {
        "body": {
          "bytes": "int"
        },
        "dataMasking": {
          "headers": [
            {
              "mode": "string",
              "value": "string"
            }
          ],
          "queryParams": [
            {
              "mode": "string",
              "value": "string"
            }
          ]
        },
        "headers": [ "string" ]
      }
    },
    "frontend": {
      "request": {
        "body": {
          "bytes": "int"
        },
        "dataMasking": {
          "headers": [
            {
              "mode": "string",
              "value": "string"
            }
          ],
          "queryParams": [
            {
              "mode": "string",
              "value": "string"
            }
          ]
        },
        "headers": [ "string" ]
      },
      "response": {
        "body": {
          "bytes": "int"
        },
        "dataMasking": {
          "headers": [
            {
              "mode": "string",
              "value": "string"
            }
          ],
          "queryParams": [
            {
              "mode": "string",
              "value": "string"
            }
          ]
        },
        "headers": [ "string" ]
      }
    },
    "httpCorrelationProtocol": "string",
    "largeLanguageModel": {
      "logs": "string",
      "requests": {
        "maxSizeInBytes": "int",
        "messages": "string"
      },
      "responses": {
        "maxSizeInBytes": "int",
        "messages": "string"
      }
    },
    "logClientIp": "bool",
    "loggerId": "string",
    "metrics": "bool",
    "operationNameFormat": "string",
    "sampling": {
      "percentage": "int",
      "samplingType": "string"
    },
    "verbosity": "string"
  }
}

屬性值

Microsoft.ApiManagement/service/apis/diagnostics

名稱 Description 價值觀
apiVersion API 版本 '2024-10-01-preview'
名稱 資源名稱 string

約束:
最小長度 = 1
最大長度 = 80
模式 = ^[^*#&+:<>?]+$ (必要)
properties 診斷實體合約屬性。 DiagnosticContractProperties
型別 資源類型 “Microsoft.ApiManagement/service/apis/diagnostics”

BodyDiagnosticSettings (身體診斷設置)

名稱 Description 價值觀
bytes 要記錄的要求本文字節數目。 int

約束:
最大值 = 8192

資料遮罩

名稱 Description 價值觀
headers 標頭的遮罩設定 DataMaskingEntity[]
queryParams Url 查詢參數的遮罩設定 DataMaskingEntity[]

DataMaskingEntity

名稱 Description 價值觀
mode 資料遮罩模式。 “隱藏”
“面具”
value 要遮罩的實體名稱(例如標頭或查詢參數的名稱)。 字串

DiagnosticContractProperties

名稱 Description 價值觀
alwaysLog 指定不應該套用何種類型的訊息取樣設定。 'allErrors'
後端 傳入/傳出 HTTP 訊息至後端的診斷設定 PipelineDiagnosticSettings
frontend 傳入/傳出 HTTP 訊息至閘道的診斷設定。 PipelineDiagnosticSettings
HTTPCorrelationProtocol 協定 設定要用於Application Insights診斷的相互關聯通訊協定。 “遺產”
'None'
'W3C'
largeLanguageModel 大型語言模型診斷設定 LLMDiagnosticSettings
logClientIp 記錄 ClientIP。 預設值為 false。 布爾 (bool)
loggerId (記錄器識別) 目標記錄器的資源識別碼。 字串 (必要)
計量 透過 emit-metric 原則發出自訂指標。 僅適用於 Application Insights 診斷設定。 布爾 (bool)
操作名稱格式 Application Insights 遙測的作業名稱格式。 預設值為名稱。 “名字”
'Url'
取樣 診斷的取樣設定。 採樣設置
詳細程度 套用至追蹤原則所發出之追蹤的詳細資訊層級。 '錯誤'
'資訊'
'冗長'

HttpMessageDiagnostic

名稱 Description 價值觀
body 本文記錄設定。 BodyDiagnosticSettings (身體診斷設置)
資料遮罩 資料遮罩設定。 資料遮罩
headers 要記錄的 HTTP 標頭陣列。 字串[]

LLMDiagnosticSettings

名稱 Description 價值觀
記錄 指定是否應該為大型語言模型啟用預設診斷。 '已禁用'
'已啟用'
要求 大型語言模型要求的診斷設定。 LLMMessageDiagnosticSettings
回應 大型語言模型回應的診斷設定。 LLMMessageDiagnosticSettings

LLMMessageDiagnosticSettings

名稱 Description 價值觀
maxSizeInBytes 記錄的訊息大小上限(以位元組為單位)。 預設大小為 32KB。 int

約束:
最小值 = 1
最大值 = 262144
messages 指定應該記錄的訊息。 目前只有「全部」選項。 “全部”

PipelineDiagnosticSettings

名稱 Description 價值觀
要求 要求的診斷設定。 HttpMessageDiagnostic
response 回應的診斷設定。 HttpMessageDiagnostic

採樣設置

名稱 Description 價值觀
百分比 固定速率取樣的取樣率。 int

約束:
最小值 = 0
最大值 = 100
採樣類型 取樣類型。 '固定'

Terraform (AzAPI 提供者) 資源定義

服務/apis/診斷資源類型可以使用目標作業來部署:

  • 資源團體 關於每個 API 版本變更屬性的清單,請參見 變更日誌。

使用範例

Terraform 範例

部署 API 管理 服務 API 診斷記錄的基本範例。

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "component" {
  type      = "Microsoft.Insights/components@2020-02-02"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    kind = "web"
    properties = {
      Application_Type                = "web"
      DisableIpMasking                = false
      DisableLocalAuth                = false
      ForceCustomerStorageForProfiler = false
      RetentionInDays                 = 90
      SamplingPercentage              = 100
      publicNetworkAccessForIngestion = "Enabled"
      publicNetworkAccessForQuery     = "Enabled"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "service" {
  type      = "Microsoft.ApiManagement/service@2021-08-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      certificates = [
      ]
      customProperties = {
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30" = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10" = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11" = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10"         = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11"         = "false"
      }
      disableGateway      = false
      publicNetworkAccess = "Enabled"
      publisherEmail      = "pub1@email.com"
      publisherName       = "pub1"
      virtualNetworkType  = "None"
    }
    sku = {
      capacity = 0
      name     = "Consumption"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "api" {
  type      = "Microsoft.ApiManagement/service/apis@2021-08-01"
  parent_id = azapi_resource.service.id
  name      = "${var.resource_name};rev=1"
  body = {
    properties = {
      apiType    = "http"
      apiVersion = ""
      format     = "swagger-link-json"
      path       = "test"
      type       = "http"
      value      = "http://conferenceapi.azurewebsites.net/?format=json"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "logger" {
  type      = "Microsoft.ApiManagement/service/loggers@2021-08-01"
  parent_id = azapi_resource.service.id
  name      = var.resource_name
  body = {
    properties = {
      credentials = {
        instrumentationKey = azapi_resource.component.output.properties.InstrumentationKey
      }
      description = ""
      isBuffered  = true
      loggerType  = "applicationInsights"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
  lifecycle {
    ignore_changes = [body.properties.credentials.instrumentationKey]
  }
}

resource "azapi_resource" "diagnostic" {
  type      = "Microsoft.ApiManagement/service/apis/diagnostics@2021-08-01"
  parent_id = azapi_resource.api.id
  name      = "applicationinsights"
  body = {
    properties = {
      loggerId            = azapi_resource.logger.id
      operationNameFormat = "Name"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

資源格式

若要建立 Microsoft.ApiManagement/service/apis/diagnostics 資源,請將下列 Terraform 新增至範本。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.ApiManagement/service/apis/diagnostics@2024-10-01-preview"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      alwaysLog = "string"
      backend = {
        request = {
          body = {
            bytes = int
          }
          dataMasking = {
            headers = [
              {
                mode = "string"
                value = "string"
              }
            ]
            queryParams = [
              {
                mode = "string"
                value = "string"
              }
            ]
          }
          headers = [
            "string"
          ]
        }
        response = {
          body = {
            bytes = int
          }
          dataMasking = {
            headers = [
              {
                mode = "string"
                value = "string"
              }
            ]
            queryParams = [
              {
                mode = "string"
                value = "string"
              }
            ]
          }
          headers = [
            "string"
          ]
        }
      }
      frontend = {
        request = {
          body = {
            bytes = int
          }
          dataMasking = {
            headers = [
              {
                mode = "string"
                value = "string"
              }
            ]
            queryParams = [
              {
                mode = "string"
                value = "string"
              }
            ]
          }
          headers = [
            "string"
          ]
        }
        response = {
          body = {
            bytes = int
          }
          dataMasking = {
            headers = [
              {
                mode = "string"
                value = "string"
              }
            ]
            queryParams = [
              {
                mode = "string"
                value = "string"
              }
            ]
          }
          headers = [
            "string"
          ]
        }
      }
      httpCorrelationProtocol = "string"
      largeLanguageModel = {
        logs = "string"
        requests = {
          maxSizeInBytes = int
          messages = "string"
        }
        responses = {
          maxSizeInBytes = int
          messages = "string"
        }
      }
      logClientIp = bool
      loggerId = "string"
      metrics = bool
      operationNameFormat = "string"
      sampling = {
        percentage = int
        samplingType = "string"
      }
      verbosity = "string"
    }
  }
}

屬性值

Microsoft.ApiManagement/service/apis/diagnostics

名稱 Description 價值觀
名稱 資源名稱 string

約束:
最小長度 = 1
最大長度 = 80
模式 = ^[^*#&+:<>?]+$ (必要)
parent_id 此資源為父系之資源的標識碼。 類型資源的標識碼:服務/apis
properties 診斷實體合約屬性。 DiagnosticContractProperties
型別 資源類型 「Microsoft.ApiManagement/service/apis/diagnostics@2024-10-01-preview」

BodyDiagnosticSettings (身體診斷設置)

名稱 Description 價值觀
bytes 要記錄的要求本文字節數目。 int

約束:
最大值 = 8192

資料遮罩

名稱 Description 價值觀
headers 標頭的遮罩設定 DataMaskingEntity[]
queryParams Url 查詢參數的遮罩設定 DataMaskingEntity[]

DataMaskingEntity

名稱 Description 價值觀
mode 資料遮罩模式。 “隱藏”
“面具”
value 要遮罩的實體名稱(例如標頭或查詢參數的名稱)。 字串

DiagnosticContractProperties

名稱 Description 價值觀
alwaysLog 指定不應該套用何種類型的訊息取樣設定。 'allErrors'
後端 傳入/傳出 HTTP 訊息至後端的診斷設定 PipelineDiagnosticSettings
frontend 傳入/傳出 HTTP 訊息至閘道的診斷設定。 PipelineDiagnosticSettings
HTTPCorrelationProtocol 協定 設定要用於Application Insights診斷的相互關聯通訊協定。 “遺產”
'None'
'W3C'
largeLanguageModel 大型語言模型診斷設定 LLMDiagnosticSettings
logClientIp 記錄 ClientIP。 預設值為 false。 布爾 (bool)
loggerId (記錄器識別) 目標記錄器的資源識別碼。 字串 (必要)
計量 透過 emit-metric 原則發出自訂指標。 僅適用於 Application Insights 診斷設定。 布爾 (bool)
操作名稱格式 Application Insights 遙測的作業名稱格式。 預設值為名稱。 “名字”
'Url'
取樣 診斷的取樣設定。 採樣設置
詳細程度 套用至追蹤原則所發出之追蹤的詳細資訊層級。 '錯誤'
'資訊'
'冗長'

HttpMessageDiagnostic

名稱 Description 價值觀
body 本文記錄設定。 BodyDiagnosticSettings (身體診斷設置)
資料遮罩 資料遮罩設定。 資料遮罩
headers 要記錄的 HTTP 標頭陣列。 字串[]

LLMDiagnosticSettings

名稱 Description 價值觀
記錄 指定是否應該為大型語言模型啟用預設診斷。 '已禁用'
'已啟用'
要求 大型語言模型要求的診斷設定。 LLMMessageDiagnosticSettings
回應 大型語言模型回應的診斷設定。 LLMMessageDiagnosticSettings

LLMMessageDiagnosticSettings

名稱 Description 價值觀
maxSizeInBytes 記錄的訊息大小上限(以位元組為單位)。 預設大小為 32KB。 int

約束:
最小值 = 1
最大值 = 262144
messages 指定應該記錄的訊息。 目前只有「全部」選項。 “全部”

PipelineDiagnosticSettings

名稱 Description 價值觀
要求 要求的診斷設定。 HttpMessageDiagnostic
response 回應的診斷設定。 HttpMessageDiagnostic

採樣設置

名稱 Description 價值觀
百分比 固定速率取樣的取樣率。 int

約束:
最小值 = 0
最大值 = 100
採樣類型 取樣類型。 '固定'