-
Notifications
You must be signed in to change notification settings - Fork 1
/
deployAutomationAccount.json
228 lines (228 loc) · 9.6 KB
/
deployAutomationAccount.json
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccountName": {
"type": "string",
"metadata": {
"description": "The name of the Azure Automation account to deploy to."
}
},
"scheduleStartDate": {
"type": "string",
"metadata": {
"description": "Date in 'YYYY/MM/DD' format, and at least one day ahead of the current day. Used to setup the automation schedule for the start/stop VM automation"
},
"defaultValue": "2099/12/31"
},
"scheduleid01": {
"type": "string",
"metadata": {
"description": "Location for the automation account. Since this service is not available in all regions at this time, select a region in the dropdown."
},
"defaultValue": "be55e7b7-ba86-48d6-9efd-49f3d310bcb9"
},
"scheduleid02": {
"type": "string",
"metadata": {
"description": "Location for the automation account. Since this service is not available in all regions at this time, select a region in the dropdown."
},
"defaultValue": "be55e7b7-ba86-48d6-9efd-49f3d310bcc5"
},
"region": {
"type": "string"
},
"userName": {
"type": "string",
"metadata": {
"description": "The username for the Azure Automation credential."
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "The password for the Azure Automation credential."
}
}
},
"variables": {
"SingleQuote": "'",
"apiVersions": {
"automation": "2015-10-31"
},
"automationAccount": {
"sku": "Free",
"schedule01": "[parameters('scheduleid01')]",
"schedule02": "[parameters('scheduleid02')]"
}
},
"resources": [
{
"name": "[parameters('automationAccountName')]",
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "[variables('apiVersions').automation]",
"location": "[parameters('region')]",
"dependsOn": [],
"tags": {},
"properties": {
"sku": {
"name": "[variables('automationAccount').sku]"
}
}
},
{
"name": "[concat(parameters('automationAccountName'), '/Invoke-StartStopBusinessHoursVM')]",
"type": "Microsoft.Automation/automationAccounts/runbooks",
"apiVersion": "[variables('apiVersions').automation]",
"location": "[parameters('region')]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"runbookType": "PowerShell",
"logProgress": "false",
"logVerbose": "false",
"description": "Starts or Stops ARM based VM's based on tags",
"publishContentLink": {
"uri": "https://raw.githubusercontent.com/rbergertd/rds/master/startstop-runbook.ps1",
"version": "1.0.0.0"
}
}
},
{
"name": "[concat(parameters('automationAccountName'), '/Daily9AM')]",
"type": "microsoft.automation/automationAccounts/schedules",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"description": "Daily 9AM schedule",
"startTime": "[concat(parameters('scheduleStartDate'),' 09:00:00')]",
"isEnabled": "true",
"interval": "1",
"frequency": "day"
}
},
{
"name": "[concat(parameters('automationAccountName'), '/', variables('automationAccount').schedule01)]",
"type": "microsoft.automation/automationAccounts/jobSchedules",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'), '/schedules/Daily9AM')]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'), '/runbooks/Invoke-StartStopBusinessHoursVM')]"
],
"tags": {},
"properties": {
"schedule": {
"name": "Daily9AM"
},
"runbook": {
"name": "Invoke-StartStopBusinessHoursVM"
},
"parameters": {
"action": "Start"
}
}
},
{
"name": "[concat(parameters('automationAccountName'), '/Daily9PM')]",
"type": "microsoft.automation/automationAccounts/schedules",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'), '/runbooks/Invoke-StartStopBusinessHoursVM')]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"description": "Daily 9PM schedule",
"startTime": "[concat(parameters('scheduleStartDate'),' 21:00:00')]",
"isEnabled": "true",
"interval": "1",
"frequency": "day"
}
},
{
"name": "[concat(parameters('automationAccountName'), '/', variables('automationAccount').schedule02)]",
"type": "microsoft.automation/automationAccounts/jobSchedules",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'), '/runbooks/Invoke-StartStopBusinessHoursVM')]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'), '/schedules/Daily9PM')]"
],
"tags": {},
"properties": {
"schedule": {
"name": "Daily9PM"
},
"runbook": {
"name": "Invoke-StartStopBusinessHoursVM"
}
}
},
{
"name": "[concat(parameters('automationAccountName'), '/StartStopTagKeyValuePair') ]",
"type": "microsoft.automation/automationAccounts/variables",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"description": "",
"isEncrypted": 0,
"type": "string",
"value": "'BusinessHours:true'"
}
},
{
"name": "[concat(parameters('automationAccountName'), '/AzureSubscriptionId') ]",
"type": "microsoft.automation/automationAccounts/variables",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"description": "",
"isEncrypted": 0,
"type": "string",
"value": "[concat(variables('singleQuote'),subscription().subscriptionId,variables('singleQuote'))]"
}
},
{
"name": "[concat(parameters('automationAccountName'), '/AzureTenantId') ]",
"type": "microsoft.automation/automationAccounts/variables",
"apiVersion": "[variables('apiVersions').automation]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"description": "",
"isEncrypted": 0,
"type": "string",
"value": "[concat(variables('singleQuote'),subscription().tenantId,variables('singleQuote'))]"
}
},
{
"name": "[concat(parameters('automationAccountName'), '/AzureServicePrincipal') ]",
"type": "microsoft.automation/automationAccounts/credentials",
"apiVersion": "[variables('apiVersions').automation]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
],
"tags": {},
"properties": {
"userName": "[parameters('userName')]",
"password": "[parameters('password')]"
}
}
],
"outputs": {}
}