-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathstorageAccount.bicep
83 lines (72 loc) · 1.99 KB
/
storageAccount.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
// Parameters
@description('Specifies the globally unique name for the storage account used to store the boot diagnostics logs of the virtual machine.')
param name string = 'boot${uniqueString(resourceGroup().id)}'
@description('Specifies whether to create containers.')
param createContainers bool = true
@description('Specifies an array of containers to create.')
param containerNames array
@description('Specifies the resource id of the Log Analytics workspace.')
param workspaceId string
@description('Specifies the location.')
param location string = resourceGroup().location
@description('Specifies the resource tags.')
param tags object
// Variables
var diagnosticSettingsName = 'diagnosticSettings'
var logCategories = [
'StorageRead'
'StorageWrite'
'StorageDelete'
]
var metricCategories = [
'Transaction'
]
var logs = [for category in logCategories: {
category: category
enabled: true
retentionPolicy: {
enabled: true
days: 0
}
}]
var metrics = [for category in metricCategories: {
category: category
enabled: true
retentionPolicy: {
enabled: true
days: 0
}
}]
// Resources
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: name
location: location
tags: tags
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
// Containers live inside of a blob service
resource blobService 'blobServices' = {
name: 'default'
// Creating containers with provided names if contition is true
resource containers 'containers' = [for containerName in containerNames: if(createContainers) {
name: containerName
properties: {
publicAccess: 'None'
}
}]
}
}
resource blobServiceDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagnosticSettingsName
scope: storageAccount::blobService
properties: {
workspaceId: workspaceId
logs: logs
metrics: metrics
}
}
// Outputs
output id string = storageAccount.id
output name string = storageAccount.name