-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.bicep
213 lines (201 loc) · 4.92 KB
/
template.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
211
212
213
metadata description = 'File to deploy web application'
@description('Size of the Virtual Machine to Provision')
param vmsize string
@description('Admin user name')
param adminuser string
@description('Should be between 6-72 characters long and a combination of Upper case, lower case, numbers and special chars.')
@secure()
param adminpassword string
@description('Location')
param location string
resource appstorage39202192 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: toLower('appstorage39202192')
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'Storage'
}
resource application_IP 'Microsoft.Network/publicIPAddresses@2023-04-01' = {
name: 'application-IP'
location: location
properties: {
publicIPAllocationMethod: 'Static'
}
}
resource app_nsg 'Microsoft.Network/networkSecurityGroups@2023-04-01' = {
name: 'app-nsg'
location: location
properties: {
securityRules: [
{
name: 'allow_HTTP'
properties: {
description: 'Allow HTTP Access'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '80'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 100
direction: 'Inbound'
}
}
{
name: 'allow_SSH'
properties: {
description: 'Allow SSH Access'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '22'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 101
direction: 'Inbound'
}
}
{
name: 'postgresql_port'
properties: {
description: 'Allow DB Access'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '5432'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 102
direction: 'Inbound'
}
}
]
}
}
resource app_vn 'Microsoft.Network/virtualNetworks@2023-04-01' = {
name: 'app-vn'
location: location
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
subnets: [
{
name: 'app-subnet1'
properties: {
addressPrefix: '10.0.0.0/24'
networkSecurityGroup: {
id: app_nsg.id
}
}
}
]
}
}
resource app_nic 'Microsoft.Network/networkInterfaces@2023-04-01' = {
name: 'app-nic'
location: location
properties: {
ipConfigurations: [
{
name: 'ipConfig1'
properties: {
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
id: application_IP.id
}
subnet: {
id: resourceId('Microsoft.Network/virtualNetworks/subnets', 'app-vn', 'app-subnet1')
}
}
}
]
}
dependsOn: [
app_vn
]
}
resource app 'Microsoft.Compute/virtualMachines@2023-03-01' = {
name: 'app'
location: location
properties: {
hardwareProfile: {
vmSize: vmsize
}
osProfile: {
computerName: 'app'
adminUsername: adminuser
adminPassword: adminpassword
}
storageProfile: {
imageReference: {
publisher: 'Canonical'
offer: 'UbuntuServer'
sku: '18.04-lts'
version: 'latest'
}
osDisk: {
name: 'app-OSDisk39202191'
caching: 'ReadWrite'
createOption: 'FromImage'
}
}
networkProfile: {
networkInterfaces: [
{
id: app_nic.id
}
]
}
diagnosticsProfile: {
bootDiagnostics: {
enabled: true
storageUri: appstorage39202192.properties.primaryEndpoints.blob
}
}
}
}
resource appExtension 'Microsoft.Compute/virtualMachines/extensions@2021-04-01' = {
parent: app
name: 'customScript1'
location: location
tags: {
displayName: 'customScript1 for Linux VM'
}
properties: {
publisher: 'Microsoft.Azure.Extensions'
type: 'CustomScript'
typeHandlerVersion: '2.0'
settings: {
// Assuming the script is hosted publicly
fileUris: ['https://github.com/rahul7thube/AzureApp/raw/main/ansible-playbooks/install-playbook.sh']
commandToExecute: 'bash install-playbook.sh'
}
}
}
/*resource app_customScript1 'Microsoft.Compute/virtualMachines/extensions@2023-03-01' = {
parent: app
name: 'customScript1'
location: location
tags: {
displayName: 'customScript1 for Linux VM'
}
properties: {
publisher: 'Microsoft.Azure.Extensions'
type: 'CustomScript'
typeHandlerVersion: '2.1'
autoUpgradeMinorVersion: true
settings: {
fileUris: [
'https://github.com/gopi-s-ht/EchoApplication/raw/main/web_server_init.sh'
]
}
protectedSettings: {
commandToExecute: 'sh web_server_init.sh'
}
}
}*/
output application_IP string = application_IP.properties.ipAddress