共用方式為


Bicep 錯誤/警告碼 - BCP035

當您的資源定義遺漏必要的屬性時,就會發生此錯誤/警告。

錯誤/警告描述

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

解決方案

將遺漏的屬性新增至資源定義。

範例

下列範例會引發 virtualNetworkGateway1virtualNetworkGateway2警告:

var networkConnectionName = 'testConnection'
var location = 'eastus'
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 = 'eastus'
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' 
  }
}

下列範例會引發 outValue 的錯誤,因為遺漏必要的屬性值

@discriminator('type')
type taggedUnion = {type: 'foo', value: int} | {type: 'bar', value: bool}

output outValue taggedUnion = {type: 'foo'}

您可以藉由新增遺漏的屬性來修正此問題:

@discriminator('type')
type taggedUnion = {type: 'foo', value: int} | {type: 'bar', value: bool}

output outValue taggedUnion = {type: 'foo', value: 3}

下一步

如需 Bicep 錯誤和警告碼的詳細資訊,請參閱 Bicep 核心診斷