Skip to content

Commit 5e73204

Browse files
committed
feat: Add storage accounts with encryption examples
1 parent 94369c4 commit 5e73204

File tree

3 files changed

+96
-9
lines changed

3 files changed

+96
-9
lines changed
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
storage
2-
| app.bicep:2:1:10:1 | StorageAccount |
3-
| app.bicep:13:1:34:1 | StorageAccount |
4-
| app.bicep:37:1:48:1 | StorageAccount |
2+
| app.bicep:2:1:10:1 | StorageAccount[examplestorage1] |
3+
| app.bicep:13:1:34:1 | StorageAccount[examplestorage2] |
4+
| app.bicep:37:1:48:1 | StorageAccount[examplestorage3] |
5+
| app.bicep:51:1:63:1 | StorageAccount[examplestorage4] |
6+
| app.bicep:66:1:83:1 | StorageAccount[examplestorage5] |
7+
| app.bicep:86:1:117:1 | StorageAccount[examplestorage6] |
58
poolDisks
6-
| app.bicep:86:1:104:1 | DiskPools | app.bicep:51:1:64:1 | ResourceDeclaration |
7-
| app.bicep:86:1:104:1 | DiskPools | app.bicep:67:1:83:1 | ResourceDeclaration |
9+
| app.bicep:155:1:173:1 | DiskPools | app.bicep:120:1:133:1 | Disks |
10+
| app.bicep:155:1:173:1 | DiskPools | app.bicep:136:1:152:1 | Disks |
11+
diskEncryption
12+
| app.bicep:136:1:152:1 | Disks | app.bicep:148:17:150:5 | EncryptionSettings |
13+
accountEncryption
14+
| app.bicep:51:1:63:1 | StorageAccount[examplestorage4] | app.bicep:59:17:61:5 | EncryptionSettings |
15+
| app.bicep:66:1:83:1 | StorageAccount[examplestorage5] | app.bicep:74:17:81:5 | EncryptionSettings |
16+
| app.bicep:86:1:117:1 | StorageAccount[examplestorage6] | app.bicep:94:17:115:5 | EncryptionSettings |
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import bicep
22

3-
query predicate storage(Storage::StorageAccounts storageAccount) {
4-
any()
3+
query predicate storage(Storage::StorageAccounts storageAccount) { any() }
4+
5+
query predicate poolDisks(Storage::DiskPools pool, Storage::Disks disk) { pool.getDisks() = disk }
6+
7+
query predicate diskEncryption(
8+
Storage::Disks disk, Storage::DiskEncryption::EncryptionSettings encryptionSettings
9+
) {
10+
disk.getEncryptionSettings() = encryptionSettings
511
}
612

7-
query predicate poolDisks(Storage::DiskPools pool, Storage::Disks disk) {
8-
pool.getDisks() = disk
13+
query predicate accountEncryption(
14+
Storage::StorageAccounts storageAccount,
15+
Storage::DiskEncryption::EncryptionSettings encryptionSettings
16+
) {
17+
storageAccount.getEncryptionSettings() = encryptionSettings
918
}

ql/test/library-tests/frameworks/storage/app.bicep

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,75 @@ resource storageAccount3 'Microsoft.Storage/storageAccounts@2022-09-01' = {
4747
}
4848
}
4949

50+
// Example 4: Storage account with Microsoft-managed keys (default encryption)
51+
resource storageAccount4 'Microsoft.Storage/storageAccounts@2022-09-01' = {
52+
name: 'examplestorage4'
53+
location: 'eastus2'
54+
sku: {
55+
name: 'Standard_LRS'
56+
}
57+
kind: 'StorageV2'
58+
properties: {
59+
encryption: {
60+
keySource: 'Microsoft.Storage'
61+
}
62+
}
63+
}
64+
65+
// Example 5: Storage account with customer-managed keys from Key Vault
66+
resource storageAccount5 'Microsoft.Storage/storageAccounts@2022-09-01' = {
67+
name: 'examplestorage5'
68+
location: 'uksouth'
69+
sku: {
70+
name: 'Standard_GRS'
71+
}
72+
kind: 'StorageV2'
73+
properties: {
74+
encryption: {
75+
keySource: 'Microsoft.Keyvault'
76+
keyvaultproperties: {
77+
keyname: 'my-key'
78+
keyvaulturi: 'https://myvault.vault.azure.net/'
79+
keyversion: '1234567890abcdef'
80+
}
81+
}
82+
}
83+
}
84+
85+
// Example 6: Storage account with per-service encryption and infrastructure encryption
86+
resource storageAccount6 'Microsoft.Storage/storageAccounts@2022-09-01' = {
87+
name: 'examplestorage6'
88+
location: 'australiaeast'
89+
sku: {
90+
name: 'Standard_ZRS'
91+
}
92+
kind: 'StorageV2'
93+
properties: {
94+
encryption: {
95+
keySource: 'Microsoft.Storage'
96+
requireInfrastructureEncryption: true
97+
services: {
98+
blob: {
99+
enabled: true
100+
keyType: 'Account'
101+
}
102+
file: {
103+
enabled: true
104+
keyType: 'Service'
105+
}
106+
queue: {
107+
enabled: false
108+
keyType: 'Account'
109+
}
110+
table: {
111+
enabled: true
112+
keyType: 'Account'
113+
}
114+
}
115+
}
116+
}
117+
}
118+
50119
// Example 1: Managed disk with Standard_LRS
51120
resource disk1 'Microsoft.Compute/disks@2022-07-02' = {
52121
name: 'exampledisk1'

0 commit comments

Comments
 (0)