Linter 규칙 - JSON null 간소화
이 규칙은 json('null')
을 찾습니다.
Linter 규칙 코드
Bicep 구성 파일의 다음 값을 사용하여 규칙 설정을 사용자 지정합니다.
simplify-json-null
솔루션
다음 예제는 json('null')
이 사용되었으므로 이 테스트에 실패합니다.
@description('The name of the API Management service instance')
param apiManagementServiceName string = 'apiservice${uniqueString(resourceGroup().id)}'
@description('The email address of the owner of the service')
@minLength(1)
param publisherEmail string
@description('The name of the owner of the service')
@minLength(1)
param publisherName string
@description('The pricing tier of this API Management service')
@allowed([
'Premium'
])
param sku string = 'Premium'
@description('The instance size of this API Management service.')
param skuCount int = 3
@description('Location for all resources.')
param location string = resourceGroup().location
@description('Zone numbers e.g. 1,2,3.')
param availabilityZones array = [
'1'
'2'
'3'
]
resource apiManagementService 'Microsoft.ApiManagement/service@2023-05-01-preview' = {
name: apiManagementServiceName
location: location
zones: ((length(availabilityZones) == 0) ? json('null') : availabilityZones)
sku: {
name: sku
capacity: skuCount
}
identity: {
type: 'SystemAssigned'
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
}
}
json('null')
을 null
로 바꿔 구문을 단순화할 수 있습니다.
@description('The name of the API Management service instance')
param apiManagementServiceName string = 'apiservice${uniqueString(resourceGroup().id)}'
@description('The email address of the owner of the service')
@minLength(1)
param publisherEmail string
@description('The name of the owner of the service')
@minLength(1)
param publisherName string
@description('The pricing tier of this API Management service')
@allowed([
'Premium'
])
param sku string = 'Premium'
@description('The instance size of this API Management service.')
param skuCount int = 3
@description('Location for all resources.')
param location string = resourceGroup().location
@description('Zone numbers e.g. 1,2,3.')
param availabilityZones array = [
'1'
'2'
'3'
]
resource apiManagementService 'Microsoft.ApiManagement/service@2023-05-01-preview' = {
name: apiManagementServiceName
location: location
zones: ((length(availabilityZones) == 0) ? null : availabilityZones)
sku: {
name: sku
capacity: skuCount
}
identity: {
type: 'SystemAssigned'
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
}
}
다음 스크린샷과 같이 빠른 수정을 선택하여 구문을 간소화할 수 있습니다.
다음 단계
Linter에 관한 자세한 내용은 Bicep Linter 사용을 참조하세요.