summaryrefslogtreecommitdiff
path: root/testfiles/sample.bicep
blob: 8fc6f8ac6a987438f3371e56caffaccbcfddce75 (plain)
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
/* 
  Test Bicep File for UDL Highlighting
  Keywords: metadata, targetScope, resource, module, param, var, output, for, in, if, existing, import, as, type, with, using, extends, func, assert, extension
  Also includes: true, false, null, and, or, not, any, concat, format, replace, split, uniqueString, resourceId, reference, json, int, bool, string, array, object, union, intersection, length, substring
*/

#disable-next-line what-if-short-circuiting

// Set the target scope for the deployment.
targetScope = 'subscription'

@description('The deployment location')
param location string = 'eastus'

@secure()
param adminPassword string

param adminUsername string = 'adminUser'

// Variable using built-in functions (Keywords8) and Keywords1 (concat, uniqueString)
var storageName = toLower(concat('stor', uniqueString(resourceGroup().id)))

// Examples of built-in functions (Keywords8)
var formattedString   = format('Storage Account: {0}', storageName)
var replacedString    = replace('Hello World', 'World', 'Bicep')
var splittedArray     = split('a,b,c', ',')
var resId             = resourceId('Microsoft.Storage/storageAccounts', storageName)
var refResult         = reference(resId)
var jsonResult        = json('{ "key": "value" }')
var intValue          = int('123')
var boolValue         = bool('true')
var stringValue       = string(456)
var arrayValue        = array(789)
var objectValue       = object('{ "a": 1 }')
var unionResult       = union([1,2,3], [4,5,6])
var intersectionResult= intersection([1,2,3,4], [3,4,5,6])
var lengthValue       = length([10,20,30])
var substringValue    = substring('Bicep${resId}', 1, 3)
var base64Text        = base64(inputString)

// Logical expressions using Keywords2 (true, false, null) and Keywords3 (and, or, not)
var condition = (location == 'eastus') ? true : false
var logicTest = (true and false) or not(true)
var anyValue  = any([null, false, 0])
var multiplication = 5*5

// Using a for-expression with Keywords1 (for, in)
var arrayOfValues = [for i in range(0, 3): i]

// Resource declaration using Keywords1 (resource, metadata)
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
  name: storageName
  location: location
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
  // (metadata used here as a comment for demonstration)
  /* metadata: This resource uses standard settings */
}

// Conditional resource deployment using Keywords1 (if)
resource conditionalResource 'Microsoft.Storage/storageAccounts@2021-04-01' = if (location == 'eastus') {
  name: concat(storageName, 'east')
  location: location
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
}

// Referencing an existing resource using Keywords1 (existing)
resource existingVNet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
  name: 'myVnet'
}

// Module deployment using Keywords1 (module)
module networkModule 'network.bicep' = {
  name: 'networkDeploy'
  params: {
    location: location
  }
}

// Output declaration using Keywords1 (output)
output storageAccountId string = storageAccount.id

// Additional keywords (import, as, with, using, extends, func, assert, extension)
// are added here in comments for highlighting purposes.
//
// import, as, with, using, extends, func, assert, extension: These keywords are here solely for testing highlighting.