-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
256 lines (225 loc) · 7.14 KB
/
main.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
param publisherEmail string
param publisherName string
@allowed([
'Developer'
'Standard'
'Premium'
])
param sku string = 'Standard'
param skuCount int = 1
@secure()
param mutualAuthenticationCertificate string
param certificatePassword string
param eventHubNamespaceConnectionString string
@secure()
param googleClientSecret string
@secure()
param openIdConnectClientSecret string
param tenantPolicy string
param apiPolicy string
param operationPolicy string
param productPolicy string
param location string = resourceGroup().location
var apiManagementServiceName = 'apiservice${uniqueString(resourceGroup().id)}'
resource apiManagementService 'Microsoft.ApiManagement/service@2020-06-01-preview' = {
name: apiManagementServiceName
location: location
sku: {
name: sku
capacity: skuCount
}
properties: {
publisherName: publisherName
publisherEmail: publisherEmail
}
}
resource policy 'Microsoft.ApiManagement/service/policies@2020-06-01-preview' = {
name: '${apiManagementService.name}/policy'
properties: {
value: tenantPolicy
}
}
resource petStoreApiExample 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = {
name: '${apiManagementService.name}/PetStoreSwaggerImportExample'
properties: {
format: 'swagger-link-json'
value: 'http://petstore.swagger.io/v2/swagger.json'
path: 'examplepetstore'
}
}
resource exampleApi 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleApi'
properties: {
displayName: 'Example API Name'
description: 'Description for example API'
serviceUrl: 'https://example.net'
path: 'exampleapipath'
protocols: [
'https'
]
}
}
resource exampleApiOperationDelete 'Microsoft.ApiManagement/service/apis/operations@2020-06-01-preview' = {
name: '${exampleApi.name}/exampleOperationsDELETE'
properties: {
displayName: 'DELETE resource'
method: 'DELETE'
urlTemplate: '/resource'
description: 'A demonstration of a DELETE call'
}
}
resource exampleApiOperationGet 'Microsoft.ApiManagement/service/apis/operations@2020-06-01-preview' = {
name: '${exampleApi.name}/exampleOperationsGET'
properties: {
displayName: 'GET resource'
method: 'GET'
urlTemplate: '/resource'
description: 'A demonstration of a GET call'
}
}
resource exampleApiOperationGetPolicy 'Microsoft.ApiManagement/service/apis/operations/policies@2020-06-01-preview' = {
name: '${exampleApiOperationGet.name}/policy'
properties: {
value: operationPolicy
}
}
resource exampleApiWithPolicy 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleApiWithPolicy'
properties: {
displayName: 'Example API Name with policy'
description: 'Description for example API with policy'
serviceUrl: 'https://examplewithpolicy.net'
path: 'exampleapipolicypath'
protocols: [
'https'
]
}
}
resource exampleApiWithPolicyPolicy 'Microsoft.ApiManagement/service/apis/operations/policies@2020-06-01-preview' = {
name: '${exampleApiWithPolicy.name}/policy'
properties: {
value: apiPolicy
}
}
resource exampleProduct 'Microsoft.ApiManagement/service/products@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleProduct'
properties: {
displayName: 'Example Product name'
description: 'Description for example product'
terms: 'Terms for example product'
subscriptionRequired: true
approvalRequired: false
subscriptionsLimit: 1
state: 'published'
}
}
resource exampleProductApi 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = {
name: '${exampleProduct.name}/exampleApi'
}
resource exampleProductPolicy 'Microsoft.ApiManagement/service/products/policies@2020-06-01-preview' = {
name: '${exampleProduct.name}/policy'
properties: {
value: productPolicy
}
}
resource exampleUser1 'Microsoft.ApiManagement/service/users@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleUser1'
properties: {
firstName: 'ExampleFirstName1'
lastName: 'ExampleLastName1'
email: '[email protected]'
state: 'active'
note: 'note for example user 1'
}
}
resource exampleUser2 'Microsoft.ApiManagement/service/users@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleUser2'
properties: {
firstName: 'ExampleFirstName2'
lastName: 'ExampleLastName2'
email: '[email protected]'
state: 'active'
note: 'note for example user 2'
}
}
resource exampleUser3 'Microsoft.ApiManagement/service/users@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleUser1'
properties: {
firstName: 'ExampleFirstName3'
lastName: 'ExampleLastName3'
email: '[email protected]'
state: 'active'
note: 'note for example user 3'
}
}
resource exampleProperty 'Microsoft.ApiManagement/service/properties@2019-01-01' = {
name: '${apiManagementService.name}/exampleproperties'
properties: {
displayName: 'propertyExampleName'
value: 'propertyExampleValue'
tags: [
'exampleTag'
]
}
}
resource subscription1 'Microsoft.ApiManagement/service/subscriptions@2017-03-01' = {
name: '${apiManagementService.name}/examplesubscription1'
properties: {
displayName: 'examplesubscription1'
productId: exampleProduct.id
userId: exampleUser1.id
}
}
resource subscription2 'Microsoft.ApiManagement/service/subscriptions@2017-03-01' = {
name: '${apiManagementService.name}/examplesubscription2'
properties: {
displayName: 'examplesubscription2'
productId: exampleProduct.id
userId: exampleUser3.id
}
}
resource certificate 'Microsoft.ApiManagement/service/certificates@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleCertificate'
properties: {
data: mutualAuthenticationCertificate
password: certificatePassword
}
}
resource exampleGroup 'Microsoft.ApiManagement/service/groups@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleGroup'
properties: {
displayName: 'Example Group Name'
description: 'Example group description'
}
}
resource openIdConnectProvider 'Microsoft.ApiManagement/service/openidConnectProviders@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleOpenIdConnectProvider'
properties: {
displayName: 'exampleOpenIdConnectProviderName'
description: 'Description for example OpenId Connect provider'
metadataEndpoint: 'https://example-openIdConnect-url.net'
clientId: 'exampleClientId'
clientSecret: openIdConnectClientSecret
}
}
resource exampleLogger 'Microsoft.ApiManagement/service/loggers@2020-06-01-preview' = {
name: '${apiManagementService.name}/exampleLogger'
properties: {
loggerType: 'azureEventHub'
description: 'Description for example logger'
credentials: {
name: 'exampleEventHubName'
eventHubNamespaceConnectionString: eventHubNamespaceConnectionString
}
}
}
resource identityProvider 'Microsoft.ApiManagement/service/identityProviders@2020-06-01-preview' = {
name: any('${apiManagementService.name}/google')
properties: {
clientId: 'googleClientId'
clientSecret: googleClientSecret
}
dependsOn: [
apiManagementService
]
}