|
1 | 1 | targetScope = 'resourceGroup'
|
2 | 2 |
|
3 |
| -@minLength(1) |
4 |
| -@description('The name of the test container to create') |
5 |
| -param containerName string = 'Movies' |
| 3 | +@secure() |
| 4 | +@description('The password for the administrator') |
| 5 | +param administratorPassword string |
6 | 6 |
|
7 |
| -@minLength(1) |
8 |
| -@description('The name of the test database to create') |
9 |
| -param databaseName string = 'unittests' |
| 7 | +@description('The username for the administrator') |
| 8 | +param administratorUsername string = 'tester' |
| 9 | + |
| 10 | +@description('The list of firewall rules to install') |
| 11 | +param firewallRules FirewallRule[] = [ |
| 12 | + { startIpAddress: '0.0.0.0', endIpAddress: '0.0.0.0' } |
| 13 | +] |
10 | 14 |
|
11 | 15 | @minLength(1)
|
12 | 16 | @description('Primary location for all resources')
|
13 | 17 | param location string = resourceGroup().location
|
14 | 18 |
|
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 | 19 | @description('The name of the Mongo Server to create.')
|
20 | 20 | param serverName string
|
21 | 21 |
|
22 | 22 | @description('The list of tags to apply to all resources.')
|
23 | 23 | param tags object = {}
|
24 | 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 |
| -] |
| 25 | +@description('The tier to use for compute') |
| 26 | +@allowed([ 'Free', 'M10', 'M20', 'M25', 'M30', 'M40', 'M50', 'M60', 'M80', 'M200', 'M200-Autoscale']) |
| 27 | +param tier string = 'M10' |
105 | 28 |
|
106 | 29 | /*********************************************************************************/
|
107 | 30 |
|
108 |
| -resource account 'Microsoft.DocumentDB/databaseAccounts@2022-05-15' = { |
| 31 | +resource cluster 'Microsoft.DocumentDB/mongoClusters@2024-07-01' = { |
109 | 32 | name: toLower(serverName)
|
110 | 33 | location: location
|
111 |
| - kind: 'MongoDB' |
112 | 34 | tags: tags
|
113 | 35 | properties: {
|
114 |
| - apiProperties: { |
115 |
| - serverVersion: mongoVersion |
| 36 | + administrator: { |
| 37 | + userName: administratorUsername |
| 38 | + password: administratorPassword |
116 | 39 | }
|
117 |
| - capabilities: [ |
118 |
| - { |
119 |
| - name: 'DisableRateLimitingResponses' |
120 |
| - } |
121 |
| - ] |
122 |
| - consistencyPolicy: { |
123 |
| - defaultConsistencyLevel: 'Session' |
| 40 | + compute: { tier: tier } |
| 41 | + highAvailability: { |
| 42 | + targetMode: 'Disabled' |
124 | 43 | }
|
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 |
| 44 | + publicNetworkAccess: 'Enabled' |
| 45 | + serverVersion: '7.0' |
| 46 | + sharding: { |
| 47 | + shardCount: 1 |
146 | 48 | }
|
| 49 | + storage: { sizeGb: 32 } |
147 | 50 | }
|
148 | 51 | }
|
149 | 52 |
|
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 |
| - ] |
| 53 | +resource mongoFirewallRule 'Microsoft.DocumentDB/mongoClusters/firewallRules@2024-07-01' = [ |
| 54 | + for (fwRule, index) in firewallRules: { |
| 55 | + name: fwRule.?name ?? 'rule-${index}' |
| 56 | + parent: cluster |
| 57 | + properties: { |
| 58 | + startIpAddress: fwRule.startIpAddress |
| 59 | + endIpAddress: fwRule.endIpAddress |
176 | 60 | }
|
177 | 61 | }
|
178 |
| -} |
| 62 | +] |
| 63 | + |
179 | 64 | /*********************************************************************************/
|
180 | 65 |
|
181 | 66 | #disable-next-line outputs-should-not-contain-secrets
|
182 |
| -output MONGODB_CONNECTIONSTRING string = account.listConnectionStrings().connectionStrings[1].connectionString |
| 67 | +output MONGO_CONNECTIONSTRING string = replace(replace(cluster.listConnectionStrings().connectionStrings[0].connectionString, '<user>', administratorUsername), '<password>', administratorPassword) |
| 68 | + |
| 69 | +/*********************************************************************************/ |
| 70 | + |
| 71 | +type FirewallRule = { |
| 72 | + name: string? |
| 73 | + startIpAddress: string |
| 74 | + endIpAddress: string |
| 75 | +} |
0 commit comments