@description('CosmosDB Account Name') param cosmosAccountName string @description('CosmosDB Container Name') param cosmosContainerName string @description('CosmosDB Database Name') param cosmosDatabaseName string @description('KeyVault Name') param keyVaultName string @description('Deployment Location') param location string = resourceGroup().location @description('Log Analytics Workspace ID') param workspaceId string resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = { name: cosmosAccountName location: location kind: 'GlobalDocumentDB' properties: { consistencyPolicy: { defaultConsistencyLevel: 'Session' } locations: [ { locationName: location failoverPriority: 0 } ] databaseAccountOfferType: 'Standard' enableAutomaticFailover: true } } resource cosmosDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15' = { name: cosmosDatabaseName location: location parent: cosmosAccount properties: { resource: { id: cosmosDatabaseName } } } resource cosmosContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-05-15' = { name: cosmosContainerName location: location parent: cosmosDatabase properties: { options: { autoscaleSettings: { maxThroughput: 1000 } } resource: { id: cosmosContainerName partitionKey: { paths: [ '/tenant_id' ] kind: 'Hash' } indexingPolicy: { indexingMode: 'consistent' automatic: true includedPaths: [ { path: '/*' } ] excludedPaths: [ { path: '/"_etag"/?' } ] } } } } resource cosmosKeySecret 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = { name: '${keyVaultName}/COSMOS-KEY' properties: { value: cosmosAccount.listKeys().primaryMasterKey } } resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { name: 'diagSettings' scope: cosmosAccount properties: { logs: [ { category: 'DataPlaneRequests' enabled: true retentionPolicy: { days: 0 enabled: false } } { category: 'QueryRuntimeStatistics' enabled: true retentionPolicy: { days: 0 enabled: false } } { category: 'PartitionKeyStatistics' enabled: true retentionPolicy: { days: 0 enabled: false } } { category: 'PartitionKeyRUConsumption' enabled: true retentionPolicy: { days: 0 enabled: false } } { category: 'ControlPlaneRequests' enabled: true retentionPolicy: { days: 0 enabled: false } } ] metrics: [ { category: 'AllMetrics' enabled: true retentionPolicy: { days: 0 enabled: false } } ] logAnalyticsDestinationType: 'Dedicated' workspaceId: workspaceId } } output cosmosDocumentEndpoint string = cosmosAccount.properties.documentEndpoint