Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.24k stars 748 forks source link

Bicep linting issue for cosmosDB api version Microsoft.DocumentDB/databaseAccounts@2021-07-01-preview: The specified "object" declaration is missing the following required properties: "createMode". #5265

Open doubleyouvdb opened 2 years ago

doubleyouvdb commented 2 years ago

Bicep version Bicep CLI version 0.4.1 (e2387595c9) Bicep Visual Studio Code Plugin: v0.4.1008 Preview

Describe the bug Bicep linting warning in Visual Studio Code: The specified "object" declaration is missing the following required properties: "createMode".BCP035

To Reproduce Create a cosmosDB object in Visual Studio Code using api version Microsoft.DocumentDB/databaseAccounts@2021-07-01-preview without the createMode property:

resource cosmosDbRes 'Microsoft.DocumentDB/databaseAccounts@2021-07-01-preview' = {
  name: cosmosDb.name
  location: resourceGroup().location
  tags: union(tags, apiTypeMappings.tags[toLower(cosmosDb.apiType)])
  kind: apiTypeMappings.kind[toLower(cosmosDb.apiType)]
  properties: {
    consistencyPolicy: {
      defaultConsistencyLevel: cosmosDb.consistencyPolicy.defaultConsistencyLevel
      maxStalenessPrefix: consistencyPolicyMapping[cosmosDb.consistencyPolicy.defaultConsistencyLevel].maxStalenessPrefix
      maxIntervalInSeconds: consistencyPolicyMapping[cosmosDb.consistencyPolicy.defaultConsistencyLevel].maxIntervalInSeconds
    }
    locations: union(locations, defaultLocation)
    databaseAccountOfferType: 'Standard'
    isVirtualNetworkFilterEnabled: !empty(cosmosDb.virtualNetworkRules)
    enableAutomaticFailover: cosmosDb.enableAutomaticFailover
    capabilities: apiTypeMappings.capabilities[toLower(cosmosDb.apiType)]
    enableMultipleWriteLocations: cosmosDb.enableMultipleWriteLocations
    enableCassandraConnector: cosmosDb.apiType =~ 'Cassandra' && cosmosDb.enableCassandraConnector
    connectorOffer: 'Small'
    disableKeyBasedMetadataWriteAccess: cosmosDb.disableKeyBasedMetadataWriteAccess
    keyVaultKeyUri: cosmosDb.keyVaultKeyUri
    publicNetworkAccess: cosmosDb.publicNetworkAccess
    enableFreeTier: cosmosDb.enableFreeTier
    apiProperties: cosmosDb.apiType =~ 'MongoDB' && !empty(cosmosDb.serverVersion) ? {
      'serverVersion': cosmosDb.serverVersion
     } : {}
    enableAnalyticalStorage: cosmosDb.enableAnalyticalStorage
    backupPolicy: backupPolicy[toLower(cosmosDb.backupPolicy.type)]
    cors: cosmosDb.apiType =~ 'SQL' && !empty(cosmosDb.corsAllowedOrigins) ? [
      {
        'allowedOrigins': cosmosDb.corsAllowedOrigins
      }
    ] : []
    ipRules: [for ipRange in (!empty(cosmosDb.ipRangeFilter) ? split(cosmosDb.ipRangeFilter, ',') : []) : {
      ipAddressOrRange: ipRange
    }]
    virtualNetworkRules: [for (virtualNetworkRule, i) in cosmosDb.virtualNetworkRules: {
      id: subnets[i].id
      ignoreMissingVNetServiceEndpoint: true
    }]
  }
}

To workaround add the property: createMode: 'Default' OR use api version Microsoft.DocumentDB/databaseAccounts@2021-06-15 for the same cosmosDB object.

slavizh commented 2 years ago

+1

alex-frankel commented 2 years ago

Adding @markjbrown to help triage the swagger inconsistency.

markjbrown commented 2 years ago

This is caused because createMode is defined as required in our swagger here.

This is a preview version and as noted the GA version of this does not produce the same error.

alex-frankel commented 2 years ago

@doubleyouvdb -- can you confirm if the deployment works with this api version if createMode is not included in the resource properties?

doubleyouvdb commented 2 years ago

@doubleyouvdb -- can you confirm if the deployment works with this api version if createMode is not included in the resource properties?

Yes, I can confirm this works.