Compartir a través de

Bicep 错误/警告代码 - BCP035

当资源定义缺少所需属性时,会发生此错误/警告。

错误/警告说明

The specified <date-type> declaration is missing the following required properties: <property-name>.

解决方案

将缺少的属性添加到资源定义。

示例

以下示例引发了 virtualNetworkGateway1 和 virtualNetworkGateway2 的警告:

var networkConnectionName = 'testConnection'
var location = 'chinanorth3'
var vnetGwAId = 'gatewayA'
var vnetGwBId = 'gatewayB'

resource networkConnection 'Microsoft.Network/connections@2023-11-01' = {
  name: networkConnectionName
  location: location
  properties: {
    virtualNetworkGateway1: {
      id: vnetGwAId
    }
    virtualNetworkGateway2: {
      id: vnetGwBId
    }

    connectionType: 'Vnet2Vnet' 
  }
}

警告为:

The specified "object" declaration is missing the following required properties: "properties". If this is an inaccuracy in the documentation, please report it to the Bicep Team.

可以通过模板参考验证缺少的属性。 如果你看到 Visual Studio Code 中的警告,请将光标悬停在资源符号名称上,然后选择“查看文档”以打开模板参考。

可以通过添加缺少的属性来解决此问题:

var networkConnectionName = 'testConnection'
var location = 'chinanorth3'
var vnetGwAId = 'gatewayA'
var vnetGwBId = 'gatewayB'

resource networkConnection 'Microsoft.Network/connections@2023-11-01' = {
  name: networkConnectionName
  location: location
  properties: {
    virtualNetworkGateway1: {
      id: vnetGwAId
      properties:{}
    }
    virtualNetworkGateway2: {
      id: vnetGwBId
      properties:{}
    }

    connectionType: 'Vnet2Vnet' 
  }
}

后续步骤

有关 Bicep 错误和警告代码的详细信息,请参阅 Bicep 警告和错误