共用方式為


Logger - Create Or Update

建立或 匯報 記錄器。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}?api-version=2022-08-01

URI 參數

名稱 位於 必要 類型 Description
loggerId
path True

string

記錄器標識碼。 在 API 管理 服務實例中必須是唯一的。

Regex 模式: ^[^*#&+:<>?]+$

resourceGroupName
path True

string

資源群組的名稱。 名稱不區分大小寫。

serviceName
path True

string

API 管理 服務的名稱。

Regex 模式: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$

subscriptionId
path True

string

目標訂用帳戶的標識碼。

api-version
query True

string

用於此作業的 API 版本。

要求標頭

名稱 必要 類型 Description
If-Match

string

實體的 ETag。 建立實體時不需要,但在更新實體時則為必要專案。

要求本文

名稱 必要 類型 Description
properties.loggerType True

LoggerType

記錄器類型。

properties.credentials

object

azureEventHub 記錄器之事件中樞的名稱和 SendRule 連接字串。 applicationInsights 記錄器的檢測密鑰。

properties.description

string

記錄器描述。

properties.isBuffered

boolean

在發佈之前,記錄是否在記錄器中緩衝處理。 默認值假設為 true。

properties.resourceId

string

Azure 事件中樞資源或 Azure 應用程式 Insights 資源) 記錄目標 (Azure 資源識別符。

回應

名稱 類型 Description
200 OK

LoggerContract

已成功更新現有的記錄器。

標題

ETag: string

201 Created

LoggerContract

已成功建立記錄器。

標題

ETag: string

Other Status Codes

ErrorResponse

描述作業失敗原因的錯誤回應。

安全性

azure_auth

Azure Active Directory OAuth2 Flow。

類型: oauth2
Flow: implicit
授權 URL: https://login.microsoftonline.com/common/oauth2/authorize

範圍

名稱 Description
user_impersonation 模擬您的用戶帳戶

範例

ApiManagementCreateAILogger
ApiManagementCreateEHLogger

ApiManagementCreateAILogger

範例要求

PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/loggerId?api-version=2022-08-01

{
  "properties": {
    "loggerType": "applicationInsights",
    "description": "adding a new logger",
    "credentials": {
      "instrumentationKey": "11................a1"
    }
  }
}

範例回覆

{
  "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/loggerId",
  "type": "Microsoft.ApiManagement/service/loggers",
  "name": "loggerId",
  "properties": {
    "loggerType": "applicationInsights",
    "description": null,
    "credentials": {
      "instrumentationKey": "{{5a.......2a}}"
    },
    "isBuffered": false,
    "resourceId": "/subscriptions/subid/resourceGroups/rg1/providers/microsoft.insights/components/airesource"
  }
}
{
  "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/loggerId",
  "type": "Microsoft.ApiManagement/service/loggers",
  "name": "loggerId",
  "properties": {
    "loggerType": "applicationInsights",
    "description": null,
    "credentials": {
      "instrumentationKey": "{{5a.......2a}}"
    },
    "isBuffered": false
  }
}

ApiManagementCreateEHLogger

範例要求

PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/eh1?api-version=2022-08-01

{
  "properties": {
    "loggerType": "azureEventHub",
    "description": "adding a new logger",
    "credentials": {
      "name": "hydraeventhub",
      "connectionString": "Endpoint=sb://hydraeventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=********="
    }
  }
}

範例回覆

{
  "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/eh1",
  "type": "Microsoft.ApiManagement/service/loggers",
  "name": "eh1",
  "properties": {
    "loggerType": "azureEventHub",
    "description": "adding a new logger",
    "credentials": {
      "connectionString": "{{Logger-Credentials-5f28745bbebeeb13cc3f7301}}"
    },
    "isBuffered": true
  }
}
{
  "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/eh1",
  "type": "Microsoft.ApiManagement/service/loggers",
  "name": "eh1",
  "properties": {
    "loggerType": "azureEventHub",
    "description": "adding a new logger",
    "credentials": {
      "connectionString": "{{Logger-Credentials-5f28745bbebeeb13cc3f7301}}"
    },
    "isBuffered": true
  }
}

定義

名稱 Description
ErrorFieldContract

錯誤欄位合約。

ErrorResponse

錯誤回應。

LoggerContract

記錄器詳細數據。

LoggerType

記錄器類型。

ErrorFieldContract

錯誤欄位合約。

名稱 類型 Description
code

string

屬性層級錯誤碼。

message

string

人類可讀取的屬性層級錯誤表示法。

target

string

屬性名稱。

ErrorResponse

錯誤回應。

名稱 類型 Description
error.code

string

服務定義的錯誤碼。 此代碼會作為回應中指定之 HTTP 錯誤碼的子狀態。

error.details

ErrorFieldContract[]

在驗證錯誤時,要求中傳送的無效欄位清單。

error.message

string

人類可閱讀的錯誤表示法。

LoggerContract

記錄器詳細數據。

名稱 類型 Description
id

string

資源的完整資源識別碼。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

name

string

資源的名稱

properties.credentials

object

azureEventHub 記錄器之事件中樞的名稱和 SendRule 連接字串。 applicationInsights 記錄器的檢測密鑰。

properties.description

string

記錄器描述。

properties.isBuffered

boolean

在發佈之前,記錄是否在記錄器中緩衝處理。 默認值假設為 true。

properties.loggerType

LoggerType

記錄器類型。

properties.resourceId

string

Azure 事件中樞資源或 Azure 應用程式 Insights 資源) 記錄目標 (Azure 資源識別符。

type

string

資源類型。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts”

LoggerType

記錄器類型。

名稱 類型 Description
applicationInsights

string

Azure 應用程式 Insights 作為記錄目的地。

azureEventHub

string

Azure 事件中樞作為記錄目的地。

azureMonitor

string

Azure 監視器