1+ {
2+ "$schema" : " https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#" ,
3+ "contentVersion" : " 1.0.0.0" ,
4+ "parameters" : {
5+ "adminPassword" : {
6+ "type" : " securestring"
7+ },
8+ "adminUsername" : {
9+ "type" : " string"
10+ },
11+ "commandToExecute" : {
12+ "type" : " string"
13+ },
14+ "dataDiskName" : {
15+ "type" : " string"
16+ },
17+ "dnsNameForPublicIP" : {
18+ "type" : " string"
19+ },
20+ "nicName" : {
21+ "type" : " string"
22+ },
23+ "nsgName" : {
24+ "type" : " string"
25+ },
26+ "osDiskName" : {
27+ "type" : " string"
28+ },
29+ "publicIPAddressName" : {
30+ "type" : " string"
31+ },
32+ "storageAccountBlobEndpoint" : {
33+ "type" : " string"
34+ },
35+ "subnetName" : {
36+ "type" : " string"
37+ },
38+ "virtualNetworkName" : {
39+ "type" : " string"
40+ },
41+ "vmName" : {
42+ "type" : " string"
43+ },
44+ "vmSize" : {
45+ "type" : " string"
46+ }
47+ },
48+ "resources" : [
49+ {
50+ "apiVersion" : " [variables('networkApiVersion')]" ,
51+ "location" : " [variables('location')]" ,
52+ "name" : " [parameters('publicIPAddressName')]" ,
53+ "properties" : {
54+ "dnsSettings" : {
55+ "domainNameLabel" : " [parameters('dnsNameForPublicIP')]"
56+ },
57+ "publicIPAllocationMethod" : " [variables('publicIPAddressType')]"
58+ },
59+ "sku" : {
60+ "name" : " Standard" ,
61+ "tier" : " Regional"
62+ },
63+ "type" : " Microsoft.Network/publicIPAddresses"
64+ },
65+ {
66+ "apiVersion" : " [variables('networkApiVersion')]" ,
67+ "dependsOn" : [
68+ " [concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]" ,
69+ " [concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
70+ ],
71+ "location" : " [variables('location')]" ,
72+ "name" : " [parameters('nicName')]" ,
73+ "properties" : {
74+ "ipConfigurations" : [
75+ {
76+ "name" : " ipconfig" ,
77+ "properties" : {
78+ "privateIPAllocationMethod" : " Dynamic" ,
79+ "publicIPAddress" : {
80+ "id" : " [resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddressName'))]"
81+ },
82+ "subnet" : {
83+ "id" : " [variables('subnetRef')]"
84+ }
85+ }
86+ }
87+ ]
88+ },
89+ "type" : " Microsoft.Network/networkInterfaces"
90+ },
91+ {
92+ "apiVersion" : " [variables('computeApiVersion')]" ,
93+ "dependsOn" : [
94+ " [concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]"
95+ ],
96+ "location" : " [variables('location')]" ,
97+ "name" : " [parameters('vmName')]" ,
98+ "properties" : {
99+ "diagnosticsProfile" : {
100+ "bootDiagnostics" : {
101+ "enabled" : false
102+ }
103+ },
104+ "hardwareProfile" : {
105+ "vmSize" : " [parameters('vmSize')]"
106+ },
107+ "networkProfile" : {
108+ "networkInterfaces" : [
109+ {
110+ "id" : " [resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]"
111+ }
112+ ]
113+ },
114+ "osProfile" : {
115+ "adminUsername" : " [parameters('adminUsername')]" ,
116+ "computerName" : " [parameters('vmName')]" ,
117+ "linuxConfiguration" : {
118+ "disablePasswordAuthentication" : true ,
119+ "ssh" : {
120+ "publicKeys" : [
121+ {
122+ "keyData" : " " ,
123+ "path" : " [variables('sshKeyPath')]"
124+ }
125+ ]
126+ }
127+ }
128+ },
129+ "storageProfile" : {
130+ "imageReference" : {
131+ "offer" : " ignored00" ,
132+ "publisher" : " ignored00" ,
133+ "sku" : " ignored00" ,
134+ "version" : " latest"
135+ },
136+ "osDisk" : {
137+ "caching" : " ReadWrite" ,
138+ "createOption" : " FromImage" ,
139+ "name" : " [parameters('osDiskName')]"
140+ }
141+ }
142+ },
143+ "type" : " Microsoft.Compute/virtualMachines"
144+ },
145+ {
146+ "apiVersion" : " [variables('computeApiVersion')]" ,
147+ "condition" : " [not(empty(parameters('commandToExecute')))]" ,
148+ "dependsOn" : [
149+ " [resourceId('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
150+ ],
151+ "location" : " [variables('location')]" ,
152+ "name" : " [concat(parameters('vmName'), '/extension-customscript')]" ,
153+ "properties" : {
154+ "autoUpgradeMinorVersion" : true ,
155+ "publisher" : " Microsoft.Compute" ,
156+ "settings" : {
157+ "commandToExecute" : " [parameters('commandToExecute')]"
158+ },
159+ "type" : " CustomScriptExtension" ,
160+ "typeHandlerVersion" : " 1.10"
161+ },
162+ "type" : " Microsoft.Compute/virtualMachines/extensions"
163+ },
164+ {
165+ "apiVersion" : " [variables('networkApiVersion')]" ,
166+ "location" : " [variables('location')]" ,
167+ "name" : " [parameters('nsgName')]" ,
168+ "properties" : {
169+ "securityRules" : [
170+ {
171+ "name" : " AllowIPsToSshWinRMInbound" ,
172+ "properties" : {
173+ "access" : " Allow" ,
174+ "description" : " Allow inbound traffic from specified IP addresses" ,
175+ "destinationAddressPrefix" : " VirtualNetwork" ,
176+ "destinationPortRange" : " 0" ,
177+ "direction" : " Inbound" ,
178+ "priority" : 100 ,
179+ "protocol" : " Tcp" ,
180+ "sourceAddressPrefix" : " *" ,
181+ "sourcePortRange" : " *"
182+ }
183+ }
184+ ]
185+ },
186+ "type" : " Microsoft.Network/networkSecurityGroups"
187+ },
188+ {
189+ "apiVersion" : " [variables('networkApiVersion')]" ,
190+ "dependsOn" : [
191+ " [concat('Microsoft.Network/networkSecurityGroups/', parameters('nsgName'))]"
192+ ],
193+ "location" : " [variables('location')]" ,
194+ "name" : " [variables('virtualNetworkName')]" ,
195+ "properties" : {
196+ "addressSpace" : {
197+ "addressPrefixes" : [
198+ " [variables('addressPrefix')]"
199+ ]
200+ },
201+ "subnets" : [
202+ {
203+ "name" : " [variables('subnetName')]" ,
204+ "properties" : {
205+ "addressPrefix" : " [variables('subnetAddressPrefix')]" ,
206+ "networkSecurityGroup" : {
207+ "id" : " [resourceId('Microsoft.Network/networkSecurityGroups', parameters('nsgName'))]"
208+ }
209+ }
210+ }
211+ ]
212+ },
213+ "type" : " Microsoft.Network/virtualNetworks"
214+ }
215+ ],
216+ "variables" : {
217+ "addressPrefix" : " 10.0.0.0/16" ,
218+ "computeApiVersion" : " 2023-03-01" ,
219+ "location" : " [resourceGroup().location]" ,
220+ "networkApiVersion" : " 2023-04-01" ,
221+ "publicIPAddressType" : " Static" ,
222+ "sshKeyPath" : " [concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]" ,
223+ "subnetAddressPrefix" : " 10.0.0.0/24" ,
224+ "subnetName" : " [parameters('subnetName')]" ,
225+ "subnetRef" : " [concat(variables('vnetID'),'/subnets/',variables('subnetName'))]" ,
226+ "virtualNetworkName" : " [parameters('virtualNetworkName')]" ,
227+ "virtualNetworkResourceGroup" : " [resourceGroup().name]" ,
228+ "vmStorageAccountContainerName" : " images" ,
229+ "vnetID" : " [resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
230+ }
231+ }
0 commit comments