|
| 1 | +targetScope = 'resourceGroup' |
| 2 | + |
| 3 | +@minLength(1) |
| 4 | +@description('The name of the test container to create') |
| 5 | +param containerName string = 'Movies' |
| 6 | + |
| 7 | +@minLength(1) |
| 8 | +@description('The name of the test database to create') |
| 9 | +param databaseName string = 'unittests' |
| 10 | + |
| 11 | +@minLength(1) |
| 12 | +@description('Primary location for all resources') |
| 13 | +param location string = resourceGroup().location |
| 14 | + |
| 15 | +@allowed(['3.2', '3.6', '4.0', '4.2']) |
| 16 | +@description('Specifies the MongoDB server version to use.') |
| 17 | +param mongoVersion string = '4.2' |
| 18 | + |
| 19 | +@description('The name of the Mongo Server to create.') |
| 20 | +param serverName string |
| 21 | + |
| 22 | +@description('The list of tags to apply to all resources.') |
| 23 | +param tags object = {} |
| 24 | + |
| 25 | +/*********************************************************************************/ |
| 26 | + |
| 27 | +var compositeIndices = [ |
| 28 | + [ |
| 29 | + { path: '/BestPictureWinner', order: 'ascending' } |
| 30 | + { path: '/id', order: 'ascending' } |
| 31 | + ] |
| 32 | + [ |
| 33 | + { path: '/BestPictureWinner', order: 'descending' } |
| 34 | + { path: '/id', order: 'ascending' } |
| 35 | + ] |
| 36 | + [ |
| 37 | + { path: '/Duration', order: 'ascending' } |
| 38 | + { path: '/id', order: 'ascending' } |
| 39 | + ] |
| 40 | + [ |
| 41 | + { path: '/Duration', order: 'descending' } |
| 42 | + { path: '/id', order: 'ascending' } |
| 43 | + ] |
| 44 | + [ |
| 45 | + { path: '/Rating', order: 'ascending' } |
| 46 | + { path: '/id', order: 'ascending' } |
| 47 | + ] |
| 48 | + [ |
| 49 | + { path: '/Rating', order: 'descending' } |
| 50 | + { path: '/id', order: 'ascending' } |
| 51 | + ] |
| 52 | + [ |
| 53 | + { path: '/ReleaseDate', order: 'ascending' } |
| 54 | + { path: '/id', order: 'ascending' } |
| 55 | + ] |
| 56 | + [ |
| 57 | + { path: '/ReleaseDate', order: 'descending' } |
| 58 | + { path: '/id', order: 'ascending' } |
| 59 | + ] |
| 60 | + [ |
| 61 | + { path: '/Title', order: 'ascending' } |
| 62 | + { path: '/id', order: 'ascending' } |
| 63 | + ] |
| 64 | + [ |
| 65 | + { path: '/Title', order: 'descending' } |
| 66 | + { path: '/id', order: 'ascending' } |
| 67 | + ] |
| 68 | + [ |
| 69 | + { path: '/UpdatedAt', order: 'ascending' } |
| 70 | + { path: '/id', order: 'ascending' } |
| 71 | + ] |
| 72 | + [ |
| 73 | + { path: '/UpdatedAt', order: 'descending' } |
| 74 | + { path: '/id', order: 'ascending' } |
| 75 | + ] |
| 76 | + [ |
| 77 | + { path: '/Year', order: 'ascending' } |
| 78 | + { path: '/id', order: 'ascending' } |
| 79 | + ] |
| 80 | + [ |
| 81 | + { path: '/Year', order: 'descending' } |
| 82 | + { path: '/id', order: 'ascending' } |
| 83 | + ] |
| 84 | + [ |
| 85 | + { path: '/Year', order: 'ascending' } |
| 86 | + { path: '/Title', order: 'ascending' } |
| 87 | + { path: '/id', order: 'ascending' } |
| 88 | + ] |
| 89 | + [ |
| 90 | + { path: '/Year', order: 'descending' } |
| 91 | + { path: '/Title', order: 'ascending' } |
| 92 | + { path: '/id', order: 'ascending' } |
| 93 | + ] |
| 94 | + [ |
| 95 | + { path: '/Year', order: 'ascending' } |
| 96 | + { path: '/Title', order: 'descending' } |
| 97 | + { path: '/id', order: 'ascending' } |
| 98 | + ] |
| 99 | + [ |
| 100 | + { path: '/Year', order: 'descending' } |
| 101 | + { path: '/Title', order: 'descending' } |
| 102 | + { path: '/id', order: 'ascending' } |
| 103 | + ] |
| 104 | +] |
| 105 | + |
| 106 | +/*********************************************************************************/ |
| 107 | + |
| 108 | +resource account 'Microsoft.DocumentDB/databaseAccounts@2022-05-15' = { |
| 109 | + name: toLower(serverName) |
| 110 | + location: location |
| 111 | + kind: 'MongoDB' |
| 112 | + tags: tags |
| 113 | + properties: { |
| 114 | + apiProperties: { |
| 115 | + serverVersion: mongoVersion |
| 116 | + } |
| 117 | + capabilities: [ |
| 118 | + { |
| 119 | + name: 'DisableRateLimitingResponses' |
| 120 | + } |
| 121 | + ] |
| 122 | + consistencyPolicy: { |
| 123 | + defaultConsistencyLevel: 'Session' |
| 124 | + } |
| 125 | + databaseAccountOfferType: 'Standard' |
| 126 | + disableLocalAuth: false |
| 127 | + locations: [ |
| 128 | + { |
| 129 | + locationName: location |
| 130 | + isZoneRedundant: false |
| 131 | + } |
| 132 | + ] |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +resource database 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases@2022-05-15' = { |
| 137 | + parent: account |
| 138 | + name: databaseName |
| 139 | + tags: tags |
| 140 | + properties: { |
| 141 | + resource: { |
| 142 | + id: databaseName |
| 143 | + } |
| 144 | + options: { |
| 145 | + throughput: 400 |
| 146 | + } |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +resource collection 'Microsoft.DocumentDb/databaseAccounts/mongodbDatabases/collections@2022-05-15' = { |
| 151 | + parent: database |
| 152 | + name: containerName |
| 153 | + tags: tags |
| 154 | + properties: { |
| 155 | + resource: { |
| 156 | + id: containerName |
| 157 | + shardKey: { |
| 158 | + _id: 'Hash' |
| 159 | + } |
| 160 | + indexes: [ |
| 161 | + { |
| 162 | + key: { |
| 163 | + keys: [ |
| 164 | + '_id' |
| 165 | + ] |
| 166 | + } |
| 167 | + } |
| 168 | + { |
| 169 | + key: { |
| 170 | + keys: [ |
| 171 | + '$**' |
| 172 | + ] |
| 173 | + } |
| 174 | + } |
| 175 | + ] |
| 176 | + } |
| 177 | + } |
| 178 | +} |
| 179 | +/*********************************************************************************/ |
| 180 | + |
| 181 | +#disable-next-line outputs-should-not-contain-secrets |
| 182 | +output MONGODB_CONNECTIONSTRING string = account.listConnectionStrings().connectionStrings[1].connectionString |
0 commit comments