Linter kuralı - iç içe dağıtımda güvenli parametreler

Dış kapsamlı iç içe dağıtım kaynakları, güvenli parametreler veya liste* işlevleri için kullanılmamalıdır. Dağıtım geçmişindeki güvenli değerleri kullanıma sunmanız gerekir.

Linter kural kodu

Kural ayarlarını özelleştirmek için Bicep yapılandırma dosyasında aşağıdaki değeri kullanın:

secure-params-in-nested-deploy

Çözüm

Deployment.expressionEvaluationOptions.scope değerini olarak inner ayarlayın veya bunun yerine bir Bicep modülü kullanın.

Aşağıdaki örnek, dış kapsamlı iç içe dağıtım kaynağında güvenli bir parametreye başvuruldığından bu testte başarısız olur.

@secure()
param secureValue string

resource nested 'Microsoft.Resources/deployments@2024-03-01' = {
  name: 'nested'
  properties: {
    mode: 'Incremental'
    template: {
      '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
      contentVersion: '1.0.0.0'
      variables: {}
      resources: [
        {
          name: 'outerImplicit'
          type: 'Microsoft.Network/networkSecurityGroups'
          apiVersion: '2023-11-01'
          location: '[resourceGroup().location]'
          properties: {
            securityRules: [
              {
                name: 'outerImplicit'
                properties: {
                  description: format('{0}', secureValue)
                  protocol: 'Tcp'
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Dağıtımın properties.expressionEvaluationOptions.scope değerini 'inner' olarak ayarlayarak düzeltebilirsiniz:

@secure()
param secureValue string

resource nested 'Microsoft.Resources/deployments@2024-03-01' = {
  name: 'nested'
  properties: {
    mode: 'Incremental'
    expressionEvaluationOptions: {
      scope: 'Inner'      // Set to inner scope
    }
    template: {
      '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
      contentVersion: '1.0.0.0'
      variables: {}
      resources: [
        {
          name: 'outerImplicit'
          type: 'Microsoft.Network/networkSecurityGroups'
          apiVersion: '2023-11-01'
          location: '[resourceGroup().location]'
          properties: {
            securityRules: [
              {
                name: 'outerImplicit'
                properties: {
                  description: format('{0}', secureValue)
                  protocol: 'Tcp'
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Sonraki adımlar

Lint hakkında daha fazla bilgi için bkz . Bicep linter'i kullanma.