Skip to content

Commit eef7936

Browse files
authored
Merge pull request #277894 from mumian/0611-monitor
Fix the ARM template schema version and add Bicep
2 parents f31dca4 + 2539fab commit eef7936

File tree

1 file changed

+148
-75
lines changed

1 file changed

+148
-75
lines changed

articles/azure-monitor/logs/quick-create-workspace.md

Lines changed: 148 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,80 @@ Run the [az group create](/cli/azure/group#az-group-create) command to create a
8686

8787
For more information about Azure Monitor Logs in Azure CLI, see [Managing Azure Monitor Logs in Azure CLI](./azure-cli-log-analytics-workspace-sample.md).
8888

89+
## [Bicep](#tab/bicep)
90+
91+
The following sample uses [Microsoft.OperationalInsights workspaces](/azure/templates/microsoft.operationalinsights/workspaces?tabs=bicep&pivots=deployment-language-bicep) to create a Log Analytics workspace in Azure Monitor. For more information about Bicep, see [Bicep overview](../../azure-resource-manager/bicep/overview.md).
92+
93+
[!INCLUDE [azure-monitor-samples](../../../includes/azure-monitor-resource-manager-samples.md)]
94+
95+
### Bicep file
96+
97+
```bicep
98+
@description('Name of the workspace.')
99+
param workspaceName string
100+
101+
@description('Pricing tier: PerGB2018 or legacy tiers (Free, Standalone, PerNode, Standard or Premium) which are not available to all customers.')
102+
@allowed([
103+
'pergb2018'
104+
'Free'
105+
'Standalone'
106+
'PerNode'
107+
'Standard'
108+
'Premium'
109+
])
110+
param sku string = 'pergb2018'
111+
112+
@description('Specifies the location for the workspace.')
113+
param location string
114+
115+
@description('Number of days to retain data.')
116+
param retentionInDays int = 120
117+
118+
@description('true to use resource or workspace permissions. false to require workspace permissions.')
119+
param resourcePermissions bool
120+
121+
@description('Number of days to retain data in Heartbeat table.')
122+
param heartbeatTableRetention int
123+
124+
resource workspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
125+
name: workspaceName
126+
location: location
127+
properties: {
128+
sku: {
129+
name: sku
130+
}
131+
retentionInDays: retentionInDays
132+
features: {
133+
enableLogAccessUsingOnlyResourcePermissions: resourcePermissions
134+
}
135+
}
136+
}
137+
138+
resource workspaceName_Heartbeat 'Microsoft.OperationalInsights/workspaces/tables@2022-10-01' = {
139+
parent: workspace
140+
name: 'Heartbeat'
141+
properties: {
142+
retentionInDays: heartbeatTableRetention
143+
}
144+
}
145+
```
146+
147+
> [!NOTE]
148+
> If you specify a pricing tier of **Free**, then remove the **retentionInDays** element.
149+
150+
### Parameter file
151+
152+
```bicepparam
153+
using './main.bicep'
154+
155+
param workspaceName = 'MyWorkspace'
156+
param sku = 'pergb2018'
157+
param location = 'eastus'
158+
param retentionInDays = 120
159+
param resourcePermissions = true
160+
param heartbeatTableRetention = 30
161+
```
162+
89163
## [Resource Manager template](#tab/azure-resource-manager)
90164

91165
The following sample uses the [Microsoft.OperationalInsights workspaces](/azure/templates/microsoft.operationalinsights/workspaces?tabs=bicep) template to create a Log Analytics workspace in Azure Monitor.
@@ -97,85 +171,83 @@ For more information about Azure Resource Manager templates, see [Azure Resource
97171

98172
```json
99173
{
100-
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
174+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
101175
"contentVersion": "1.0.0.0",
102176
"parameters": {
103-
"workspaceName": {
104-
"type": "string",
105-
"metadata": {
106-
"description": "Name of the workspace."
107-
}
108-
},
109-
"sku": {
110-
"type": "string",
111-
"allowedValues": [
112-
"pergb2018",
113-
"Free",
114-
"Standalone",
115-
"PerNode",
116-
"Standard",
117-
"Premium"
118-
],
119-
"defaultValue": "pergb2018",
120-
"metadata": {
121-
"description": "Pricing tier: PerGB2018 or legacy tiers (Free, Standalone, PerNode, Standard or Premium) which are not available to all customers."
122-
}
123-
},
124-
"location": {
125-
"type": "string",
126-
"metadata": {
127-
"description": "Specifies the location for the workspace."
128-
}
129-
},
130-
"retentionInDays": {
131-
"type": "int",
132-
"defaultValue": 120,
133-
"metadata": {
134-
"description": "Number of days to retain data."
135-
}
136-
},
137-
"resourcePermissions": {
138-
"type": "bool",
139-
"metadata": {
140-
"description": "true to use resource or workspace permissions. false to require workspace permissions."
141-
}
177+
"workspaceName": {
178+
"type": "string",
179+
"metadata": {
180+
"description": "Name of the workspace."
181+
}
182+
},
183+
"sku": {
184+
"type": "string",
185+
"defaultValue": "pergb2018",
186+
"allowedValues": [
187+
"pergb2018",
188+
"Free",
189+
"Standalone",
190+
"PerNode",
191+
"Standard",
192+
"Premium"
193+
],
194+
"metadata": {
195+
"description": "Pricing tier: PerGB2018 or legacy tiers (Free, Standalone, PerNode, Standard or Premium) which are not available to all customers."
196+
}
197+
},
198+
"location": {
199+
"type": "string",
200+
"metadata": {
201+
"description": "Specifies the location for the workspace."
202+
}
203+
},
204+
"retentionInDays": {
205+
"type": "int",
206+
"defaultValue": 120,
207+
"metadata": {
208+
"description": "Number of days to retain data."
209+
}
210+
},
211+
"resourcePermissions": {
212+
"type": "bool",
213+
"metadata": {
214+
"description": "true to use resource or workspace permissions. false to require workspace permissions."
215+
}
216+
},
217+
"heartbeatTableRetention": {
218+
"type": "int",
219+
"metadata": {
220+
"description": "Number of days to retain data in Heartbeat table."
221+
}
222+
}
223+
},
224+
"resources": [
225+
{
226+
"type": "Microsoft.OperationalInsights/workspaces",
227+
"apiVersion": "2023-09-01",
228+
"name": "[parameters('workspaceName')]",
229+
"location": "[parameters('location')]",
230+
"properties": {
231+
"sku": {
232+
"name": "[parameters('sku')]"
142233
},
143-
"heartbeatTableRetention": {
144-
"type": "int",
145-
"metadata": {
146-
"description": "Number of days to retain data in Heartbeat table."
147-
}
148-
}
149-
},
150-
"resources": [
151-
{
152-
"type": "Microsoft.OperationalInsights/workspaces",
153-
"name": "[parameters('workspaceName')]",
154-
"apiVersion": "2020-08-01",
155-
"location": "[parameters('location')]",
156-
"properties": {
157-
"sku": {
158-
"name": "[parameters('sku')]"
159-
},
160-
"retentionInDays": "[parameters('retentionInDays')]",
161-
"features": {
162-
"enableLogAccessUsingOnlyResourcePermissions": "[parameters('resourcePermissions')]"
163-
}
164-
},
165-
"resources": [
166-
{
167-
"type": "Microsoft.OperationalInsights/workspaces/tables",
168-
"apiVersion": "2020-08-01",
169-
"name": "[concat(parameters('workspaceName'),'/','Heartbeat')]",
170-
"dependsOn": [
171-
"[parameters('workspaceName')]"
172-
],
173-
"properties": {
174-
"RetentionInDays": "[parameters('heartbeatTableRetention')]"
175-
}
176-
}
177-
]
234+
"retentionInDays": "[parameters('retentionInDays')]",
235+
"features": {
236+
"enableLogAccessUsingOnlyResourcePermissions": "[parameters('resourcePermissions')]"
237+
}
178238
}
239+
},
240+
{
241+
"type": "Microsoft.OperationalInsights/workspaces/tables",
242+
"apiVersion": "2022-10-01",
243+
"name": "[format('{0}/{1}', parameters('workspaceName'), 'Heartbeat')]",
244+
"properties": {
245+
"retentionInDays": "[parameters('heartbeatTableRetention')]"
246+
},
247+
"dependsOn": [
248+
"workspace"
249+
]
250+
}
179251
]
180252
}
181253
```
@@ -208,6 +280,7 @@ For more information about Azure Resource Manager templates, see [Azure Resource
208280
}
209281
}
210282
```
283+
211284
---
212285

213286
## Troubleshooting

0 commit comments

Comments
 (0)