Linter kuralı - JSON null değerini basitleştirme
Bu kural bulur json('null')
.
Linter kural kodu
Kural ayarlarını özelleştirmek için Bicep yapılandırma dosyasında aşağıdaki değeri kullanın:
simplify-json-null
Çözüm
Aşağıdaki örnek kullanıldığından bu testte json('null')
başarısız oluyor:
@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@2022-08-01' = {
name: apiManagementServiceName
location: location
zones: ((length(availabilityZones) == 0) ? json('null') : availabilityZones)
sku: {
name: sku
capacity: skuCount
}
identity: {
type: 'SystemAssigned'
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
}
}
ile değiştirerek söz dizimini json('null')
null
basitleştirebilirsiniz:
@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@2022-08-01' = {
name: apiManagementServiceName
location: location
zones: ((length(availabilityZones) == 0) ? null : availabilityZones)
sku: {
name: sku
capacity: skuCount
}
identity: {
type: 'SystemAssigned'
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
}
}
Aşağıdaki ekran görüntüsünde gösterildiği gibi Hızlı Düzeltme'yi seçerek söz dizimini basitleştirebilirsiniz:
Sonraki adımlar
Lint hakkında daha fazla bilgi için bkz . Bicep linter'i kullanma.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin