New-AzApiManagementDiagnostic
Creates a new diagnostics at the Global scope or Api Scope.
Syntax
Default (Default)
New-AzApiManagementDiagnostic
-Context <PsApiManagementContext>
-LoggerId <String>
[-DiagnosticId <String>]
[-AlwaysLog <String>]
[-ApiId <String>]
[-SamplingSetting <PsApiManagementSamplingSetting>]
[-FrontEndSetting <PsApiManagementPipelineDiagnosticSetting>]
[-BackendSetting <PsApiManagementPipelineDiagnosticSetting>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The cmdlet New-AzApiManagementDiagnostic creates a diagnostic entity either at Global scope or specific Api scope.
Examples
Example 1: Create a new Global scope Diagnostic
$context = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
$logger = Get-AzApiManagementLogger -Context $context -LoggerId "backendapisachinc"
$samplingsetting = New-AzApiManagementSamplingSetting -SamplingType fixed -SamplingPercentage 100
New-AzApiManagementDiagnostic -LoggerId $logger.LoggerId -Context $context -AlwaysLog allErrors -SamplingSetting $samplingSetting -DiagnosticId "applicationinsights"
DiagnosticId : applicationinsights
ApiId :
AlwaysLog : allErrors
LoggerId : backendapisachinc
EnableHttpCorrelationHeaders : True
SamplingSetting : Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementSamplingSetting
FrontendSetting :
BackendSetting :
Id : /subscriptions/subid/resourceGroups/Api-Default-WestUs/providers/Microsoft.ApiManagement/service/contoso/diagnostics/applicationinsights
ResourceGroupName : Api-Default-WestUs
ServiceName : contoso
This example create a diagnostic entity at the Global Scope.
Example 2: Create a diagnostic at Api scope
$context = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
$logger = Get-AzApiManagementLogger -Context $context -LoggerId azuremonitor
$samplingsetting = New-AzApiManagementSamplingSetting -SamplingType fixed -SamplingPercentage 100
$httpMessageDiagnostic = New-AzApiManagementHttpMessageDiagnostic -HeadersToLog 'Content-Type', 'User-Agent' -BodyBytesToLog 100
$pipelineDiagnostic = New-AzApiManagementPipelineDiagnosticSetting -Request $httpMessageDiagnostic -Response $httpMessageDiagnostic
New-AzApiManagementDiagnostic -LoggerId $logger.LoggerId -Context $context -ApiId httpbin -AlwaysLog allErrors -SamplingSetting $samplingsetting -FrontEndSetting $pipelineDiagnostic -BackendSetting $pipelineDiagnostic -DiagnosticId azuremonitor
DiagnosticId : azuremonitor
ApiId : httpbin
AlwaysLog : allErrors
LoggerId : azuremonitor
EnableHttpCorrelationHeaders :
SamplingSetting : Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementSamplingSetting
FrontendSetting : Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementPipelineDiagnosticSetting
BackendSetting : Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementPipelineDiagnosticSetting
Id : /subscriptions/subid/resourceGroups/Api-Default-WestUS/providers/Microsoft.ApiManagement/service/contoso/apis/httpbin/diagnostics/azuremonitor
ResourceGroupName : Api-Default-WestUS
ServiceName : contoso
The example above create a diagnostic for the API httpbin
to log the Header and 100 Bytes of Body to azuremonitor
logger.
Parameters
-AlwaysLog
Specifies for what type of messages sampling settings should not apply.
This parameter is optional.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ApiId
Identifier of existing API.
If specified will set API-scope policy.
This parameters is required.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-BackendSetting
Diagnostic setting for incoming/outgoing Http Messages to the Backend. This parameter is optional.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Context
Instance of PsApiManagementContext.
This parameter is required.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DiagnosticId
Identifier of the diagnostics entity.
This parameter is optional.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-FrontEndSetting
Diagnostic setting for incoming/outgoing Http Messages to the Gateway. This parameter is optional.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-LoggerId
Identifier of the logger to push diagnostics to.
This parameter is required.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-SamplingSetting
Sampling Setting of the Diagnostic.
This parameter is optional.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs