Api Diagnostic - Create Or Update
Creates a new Diagnostic for an API or updates an existing one.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}?api-version=2024-05-01
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
api
|
path | True |
string minLength: 1maxLength: 80 |
API identifier. Must be unique in the current API Management service instance. |
|
diagnostic
|
path | True |
string minLength: 1maxLength: 80 pattern: ^[^*#&+:<>?]+$ |
Diagnostic identifier. Must be unique in the current API Management service instance. |
|
resource
|
path | True |
string minLength: 1maxLength: 90 |
The name of the resource group. The name is case insensitive. |
|
service
|
path | True |
string minLength: 1maxLength: 50 pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$ |
The name of the API Management service. |
|
subscription
|
path | True |
string (uuid) |
The ID of the target subscription. The value must be an UUID. |
|
api-version
|
query | True |
string minLength: 1 |
The API version to use for this operation. |
Request Header
| Name | Required | Type | Description |
|---|---|---|---|
| If-Match |
string |
ETag of the Entity. Not required when creating an entity, but required when updating an entity. |
Request Body
| Name | Required | Type | Description |
|---|---|---|---|
| properties.loggerId | True |
string |
Resource Id of a target logger. |
| properties.alwaysLog |
Specifies for what type of messages sampling settings should not apply. |
||
| properties.backend |
Diagnostic settings for incoming/outgoing HTTP messages to the Backend |
||
| properties.frontend |
Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. |
||
| properties.httpCorrelationProtocol |
Sets correlation protocol to use for Application Insights diagnostics. |
||
| properties.logClientIp |
boolean |
Log the ClientIP. Default is false. |
|
| properties.metrics |
boolean |
Emit custom metrics via emit-metric policy. Applicable only to Application Insights diagnostic settings. |
|
| properties.operationNameFormat |
The format of the Operation Name for Application Insights telemetries. Default is Name. |
||
| properties.sampling |
Sampling settings for Diagnostic. |
||
| properties.verbosity |
The verbosity level applied to traces emitted by trace policies. |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
Diagnostic was successfully updated. Headers ETag: string |
|
| 201 Created |
Diagnostic was successfully created. Headers ETag: string |
|
| Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name | Description |
|---|---|
| user_impersonation | impersonate your user account |
Examples
ApiManagementCreateApiDiagnostic
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/diagnostics/applicationinsights?api-version=2024-05-01
{
"properties": {
"alwaysLog": "allErrors",
"loggerId": "/loggers/applicationinsights",
"sampling": {
"samplingType": "fixed",
"percentage": 50
},
"frontend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
},
"backend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
}
}
}
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/diagnostics/applicationinsights",
"type": "Microsoft.ApiManagement/service/apis/diagnostics",
"name": "applicationinsights",
"properties": {
"alwaysLog": "allErrors",
"loggerId": "/loggers/applicationinsights",
"sampling": {
"samplingType": "fixed",
"percentage": 50
},
"frontend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
},
"backend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
}
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/diagnostics/applicationinsights",
"type": "Microsoft.ApiManagement/service/apis/diagnostics",
"name": "applicationinsights",
"properties": {
"alwaysLog": "allErrors",
"loggerId": "/loggers/applicationinsights",
"sampling": {
"samplingType": "fixed",
"percentage": 50
},
"frontend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
},
"backend": {
"request": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
},
"response": {
"headers": [
"Content-type"
],
"body": {
"bytes": 512
}
}
}
}
}
Definitions
| Name | Description |
|---|---|
|
Always |
Specifies for what type of messages sampling settings should not apply. |
|
Body |
Body logging settings. |
|
Data |
|
|
Data |
|
|
Data |
Data masking mode. |
|
Diagnostic |
Diagnostic details. |
|
Error |
The resource management error additional info. |
|
Error |
The error detail. |
|
Error |
Error response |
|
Http |
Sets correlation protocol to use for Application Insights diagnostics. |
|
Http |
Http message diagnostic settings. |
|
Operation |
The format of the Operation Name for Application Insights telemetries. Default is Name. |
|
Pipeline |
Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. |
|
Sampling |
Sampling settings for Diagnostic. |
|
Sampling |
Sampling type. |
| Verbosity |
The verbosity level applied to traces emitted by trace policies. |
AlwaysLog
Specifies for what type of messages sampling settings should not apply.
| Value | Description |
|---|---|
| allErrors |
Always log all erroneous request regardless of sampling settings. |
BodyDiagnosticSettings
Body logging settings.
| Name | Type | Description |
|---|---|---|
| bytes |
integer (int32) maximum: 8192 |
Number of request body bytes to log. |
DataMasking
| Name | Type | Description |
|---|---|---|
| headers |
Masking settings for headers |
|
| queryParams |
Masking settings for Url query parameters |
DataMaskingEntity
| Name | Type | Description |
|---|---|---|
| mode |
Data masking mode. |
|
| value |
string |
The name of an entity to mask (e.g. a name of a header or a query parameter). |
DataMaskingMode
Data masking mode.
| Value | Description |
|---|---|
| Mask |
Mask the value of an entity. |
| Hide |
Hide the presence of an entity. |
DiagnosticContract
Diagnostic details.
| Name | Type | Description |
|---|---|---|
| id |
string |
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
| name |
string |
The name of the resource |
| properties.alwaysLog |
Specifies for what type of messages sampling settings should not apply. |
|
| properties.backend |
Diagnostic settings for incoming/outgoing HTTP messages to the Backend |
|
| properties.frontend |
Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. |
|
| properties.httpCorrelationProtocol |
Sets correlation protocol to use for Application Insights diagnostics. |
|
| properties.logClientIp |
boolean |
Log the ClientIP. Default is false. |
| properties.loggerId |
string |
Resource Id of a target logger. |
| properties.metrics |
boolean |
Emit custom metrics via emit-metric policy. Applicable only to Application Insights diagnostic settings. |
| properties.operationNameFormat |
The format of the Operation Name for Application Insights telemetries. Default is Name. |
|
| properties.sampling |
Sampling settings for Diagnostic. |
|
| properties.verbosity |
The verbosity level applied to traces emitted by trace policies. |
|
| type |
string |
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
ErrorAdditionalInfo
The resource management error additional info.
| Name | Type | Description |
|---|---|---|
| info |
object |
The additional info. |
| type |
string |
The additional info type. |
ErrorDetail
The error detail.
| Name | Type | Description |
|---|---|---|
| additionalInfo |
The error additional info. |
|
| code |
string |
The error code. |
| details |
The error details. |
|
| message |
string |
The error message. |
| target |
string |
The error target. |
ErrorResponse
Error response
| Name | Type | Description |
|---|---|---|
| error |
The error object. |
HttpCorrelationProtocol
Sets correlation protocol to use for Application Insights diagnostics.
| Value | Description |
|---|---|
| None |
Do not read and inject correlation headers. |
| Legacy |
Inject Request-Id and Request-Context headers with request correlation data. See https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md. |
| W3C |
Inject Trace Context headers. See https://w3c.github.io/trace-context. |
HttpMessageDiagnostic
Http message diagnostic settings.
| Name | Type | Description |
|---|---|---|
| body |
Body logging settings. |
|
| dataMasking |
Data masking settings. |
|
| headers |
string[] |
Array of HTTP Headers to log. |
OperationNameFormat
The format of the Operation Name for Application Insights telemetries. Default is Name.
| Value | Description |
|---|---|
| Name |
API_NAME;rev=API_REVISION - OPERATION_NAME |
| Url |
HTTP_VERB URL |
PipelineDiagnosticSettings
Diagnostic settings for incoming/outgoing HTTP messages to the Gateway.
| Name | Type | Description |
|---|---|---|
| request |
Diagnostic settings for request. |
|
| response |
Diagnostic settings for response. |
SamplingSettings
Sampling settings for Diagnostic.
| Name | Type | Description |
|---|---|---|
| percentage |
number (double) minimum: 0maximum: 100 |
Rate of sampling for fixed-rate sampling. |
| samplingType |
Sampling type. |
SamplingType
Sampling type.
| Value | Description |
|---|---|
| fixed |
Fixed-rate sampling. |
Verbosity
The verbosity level applied to traces emitted by trace policies.
| Value | Description |
|---|---|
| verbose |
All the traces emitted by trace policies will be sent to the logger attached to this diagnostic instance. |
| information |
Traces with 'severity' set to 'information' and 'error' will be sent to the logger attached to this diagnostic instance. |
| error |
Only traces with 'severity' set to 'error' will be sent to the logger attached to this diagnostic instance. |