-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.bicep
210 lines (192 loc) · 5.02 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
param publisherEmail string = '[email protected]'
param publisherName string = 'Markus'
@allowed([
'Developer'
'Standard'
'Premium'
])
param sku string = 'Developer'
param skuCount int = 1
param location string = resourceGroup().location
var logAnalyticsWorkspaceName = 'log-demo'
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = {
name: logAnalyticsWorkspaceName
location: location
properties: any({
retentionInDays: 30
features: {
searchVersion: 1
}
sku: {
name: 'Standalone'
}
})
}
resource logAnalyticsWorkspaceDiagnostics 'Microsoft.Insights/diagnosticSettings@2017-05-01-preview' = {
scope: logAnalyticsWorkspace
name: 'diagnosticSettings'
properties: {
workspaceId: logAnalyticsWorkspace.id
logs: [
{
category: 'Audit'
enabled: true
retentionPolicy: {
days: 7
enabled: true
}
}
]
metrics: [
{
category: 'AllMetrics'
enabled: true
retentionPolicy: {
days: 7
enabled: true
}
}
]
}
}
var appInsightsName = 'appi-demo'
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
name: appInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: logAnalyticsWorkspace.id
publicNetworkAccessForIngestion: 'Enabled'
publicNetworkAccessForQuery: 'Enabled'
}
}
var apiManagementServiceName = 'demoapiservice${uniqueString(resourceGroup().id)}'
resource apiManagementService 'Microsoft.ApiManagement/service@2021-08-01' = {
name: apiManagementServiceName
location: location
sku: {
name: sku
capacity: skuCount
}
properties: {
publisherName: publisherName
publisherEmail: publisherEmail
disableGateway: false
}
}
resource apiManagementServiceLogger 'Microsoft.ApiManagement/service/loggers@2021-08-01' = {
name: '${apiManagementService.name}/${appInsights.name}'
properties: {
loggerType: 'applicationInsights'
credentials: {
instrumentationKey: '{{${namedValueAppInsightsKey.properties.displayName}}}'
}
}
}
resource namedValueAppInsightsKey 'Microsoft.ApiManagement/service/namedValues@2021-08-01' = {
name: '${apiManagementService.name}/AppInsightsKey'
properties: {
displayName: 'AppInsightsKey'
value: appInsights.properties.InstrumentationKey
secret: true
tags: [
'AppInsights'
]
}
}
resource namedValueTinyUrlKey 'Microsoft.ApiManagement/service/namedValues@2021-08-01' = {
name: '${apiManagementService.name}/TinyUrlKey'
properties: {
displayName: 'TinyUrlKey'
value: '-na-'
secret: true
tags: [
'TinyUrl'
]
}
}
resource namedValueEvaluationApiKey 'Microsoft.ApiManagement/service/namedValues@2021-08-01' = {
name: '${apiManagementService.name}/EvaluationApiKey'
properties: {
displayName: 'EvaluationApiKey'
value: '-na-'
secret: true
tags: [
'Evaluation'
]
}
}
resource petStoreApiExample 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
name: '${apiManagementService.name}/PetStoreSwaggerImportExample'
properties: {
format: 'openapi+json-link'
value: 'https://petstore3.swagger.io/api/v3/openapi.json'
path: 'examplepetstore'
}
}
resource encomDevelopersProduct 'Microsoft.ApiManagement/service/products@2021-08-01' = {
name: '${apiManagementService.name}/encomDevelopers'
properties: {
displayName: 'Encom Developers'
description: 'Developers from Encom'
terms: 'Terms for Encom'
subscriptionRequired: true
approvalRequired: false
subscriptionsLimit: 1
state: 'published'
}
}
resource productStarterPetStoreApiExample 'Microsoft.ApiManagement/service/products/apis@2021-08-01' = {
name: '${apiManagementService.name}/starter/${substring(petStoreApiExample.name, lastIndexOf(petStoreApiExample.name, '/') + 1 , length(petStoreApiExample.name)-lastIndexOf(petStoreApiExample.name, '/')-1) }'
}
resource appInsightsPetStoreApiExample 'Microsoft.ApiManagement/service/apis/diagnostics@2021-08-01' = {
name: '${petStoreApiExample.name}/applicationinsights'
properties: {
loggerId: apiManagementServiceLogger.id
alwaysLog: 'allErrors'
verbosity: 'verbose'
httpCorrelationProtocol: 'W3C'
sampling: {
percentage: 100
samplingType: 'fixed'
}
backend: {
request: {
body: {
bytes: 8192
}
}
response: {
body: {
bytes: 8192
}
}
}
frontend: {
request: {
body: {
bytes: 8192
}
}
response: {
body: {
bytes: 8192
}
}
}
}
}
resource apiManagementServiceGateway 'Microsoft.ApiManagement/service/gateways@2021-08-01' = {
name: 'EvaluationGateway'
parent: apiManagementService
properties: {
description: 'For evaluation'
locationData: {
city: 'Augsburg'
countryOrRegion: 'Bavaria'
district: 'Schwabia'
name: 'Höme'
}
}
}