or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

alerts.mdbenefits.mddimensions.mdexports.mdindex.mdprice-sheet.mdquery-forecast.mdreports.mdscheduled-actions.mdviews.md

scheduled-actions.mddocs/

0

# Scheduled Actions

1

2

Automate cost management tasks with scheduled actions including email notifications, insights alerts, and custom workflows triggered by cost events. Configure automated responses to budget thresholds, cost anomalies, and billing events for proactive cost management.

3

4

## Capabilities

5

6

### Scheduled Action Management

7

8

Create, update, and manage automated actions that respond to cost events and thresholds with customizable schedules and notification settings.

9

10

```python { .api }

11

def list(filter: str = None) -> ScheduledActionListResult:

12

"""

13

List all scheduled actions.

14

15

Args:

16

filter (str): Optional filter expression for results

17

18

Returns:

19

ScheduledActionListResult: Collection of scheduled actions

20

"""

21

22

def create_or_update(

23

name: str,

24

scheduled_action: ScheduledAction,

25

if_match: str = None

26

) -> ScheduledAction:

27

"""

28

Create or update a scheduled action.

29

30

Args:

31

name (str): Name of the scheduled action

32

scheduled_action (ScheduledAction): Action configuration details

33

if_match (str): Optional ETag for concurrency control

34

35

Returns:

36

ScheduledAction: Created or updated scheduled action

37

"""

38

39

def get(name: str) -> ScheduledAction:

40

"""

41

Get a specific scheduled action by name.

42

43

Args:

44

name (str): Name of the scheduled action

45

46

Returns:

47

ScheduledAction: Scheduled action details and configuration

48

"""

49

50

def delete(name: str) -> None:

51

"""

52

Delete a scheduled action.

53

54

Args:

55

name (str): Name of the scheduled action to delete

56

"""

57

58

def run(name: str) -> None:

59

"""

60

Execute a scheduled action immediately.

61

62

Args:

63

name (str): Name of the scheduled action to execute

64

"""

65

```

66

67

### Scoped Scheduled Action Operations

68

69

Manage scheduled actions within specific scopes for targeted automation and notifications.

70

71

```python { .api }

72

def list_by_scope(scope: str, filter: str = None) -> ScheduledActionListResult:

73

"""

74

List scheduled actions for a specific scope.

75

76

Args:

77

scope (str): The scope to list actions for

78

filter (str): Optional filter expression

79

80

Returns:

81

ScheduledActionListResult: Collection of scoped scheduled actions

82

"""

83

84

def create_or_update_by_scope(

85

scope: str,

86

name: str,

87

scheduled_action: ScheduledAction,

88

if_match: str = None

89

) -> ScheduledAction:

90

"""

91

Create or update a scheduled action within a specific scope.

92

93

Args:

94

scope (str): The scope for the action

95

name (str): Name of the scheduled action

96

scheduled_action (ScheduledAction): Action configuration

97

if_match (str): Optional ETag for concurrency control

98

99

Returns:

100

ScheduledAction: Created or updated scoped action

101

"""

102

103

def get_by_scope(scope: str, name: str) -> ScheduledAction:

104

"""

105

Get a scheduled action within a specific scope.

106

107

Args:

108

scope (str): The scope containing the action

109

name (str): Name of the scheduled action

110

111

Returns:

112

ScheduledAction: Scoped scheduled action details

113

"""

114

115

def delete_by_scope(scope: str, name: str) -> None:

116

"""

117

Delete a scheduled action within a specific scope.

118

119

Args:

120

scope (str): The scope containing the action

121

name (str): Name of the scheduled action to delete

122

"""

123

124

def run_by_scope(scope: str, name: str) -> None:

125

"""

126

Execute a scheduled action within a specific scope immediately.

127

128

Args:

129

scope (str): The scope containing the action

130

name (str): Name of the scheduled action to execute

131

"""

132

```

133

134

### Name Availability Operations

135

136

Check name availability for scheduled actions to ensure unique naming.

137

138

```python { .api }

139

def check_name_availability(body: CheckNameAvailabilityRequest) -> CheckNameAvailabilityResponse:

140

"""

141

Check if a scheduled action name is available.

142

143

Args:

144

body (CheckNameAvailabilityRequest): Name availability check request

145

146

Returns:

147

CheckNameAvailabilityResponse: Availability status and reason

148

"""

149

150

def check_name_availability_by_scope(

151

scope: str,

152

body: CheckNameAvailabilityRequest

153

) -> CheckNameAvailabilityResponse:

154

"""

155

Check name availability within a specific scope.

156

157

Args:

158

scope (str): The scope to check within

159

body (CheckNameAvailabilityRequest): Name availability check request

160

161

Returns:

162

CheckNameAvailabilityResponse: Scoped availability status

163

"""

164

```

165

166

## Usage Examples

167

168

### Create Email Alert for Budget Threshold

169

170

```python

171

from azure.mgmt.costmanagement.models import (

172

ScheduledAction,

173

ScheduleProperties,

174

NotificationProperties,

175

ScheduledActionKind,

176

ScheduleFrequency,

177

ScheduledActionStatus

178

)

179

180

# Configure email notification

181

notification = NotificationProperties(

182

to=["finance-team@company.com", "manager@company.com"],

183

subject="Budget Alert: Monthly costs exceeding 80%",

184

message="Monthly spending has exceeded 80% of the allocated budget. Please review costs immediately."

185

)

186

187

# Configure schedule (weekly check)

188

schedule = ScheduleProperties(

189

frequency=ScheduleFrequency.WEEKLY,

190

hour_of_day=9,

191

days_of_week=["Monday"],

192

start_date="2024-01-01T00:00:00Z",

193

end_date="2024-12-31T23:59:59Z"

194

)

195

196

# Create scheduled action

197

budget_alert = ScheduledAction(

198

kind=ScheduledActionKind.EMAIL,

199

display_name="Weekly Budget Alert",

200

file_destination=None,

201

notification=notification,

202

schedule=schedule,

203

scope="/subscriptions/{subscription-id}",

204

status=ScheduledActionStatus.ENABLED,

205

view_id="/subscriptions/{sub-id}/providers/Microsoft.CostManagement/views/budget-view"

206

)

207

208

created_action = client.scheduled_actions.create_or_update(

209

name="weekly-budget-alert",

210

scheduled_action=budget_alert

211

)

212

213

print(f"Created scheduled action: {created_action.display_name}")

214

```

215

216

### List and Monitor Scheduled Actions

217

218

```python

219

# List all scheduled actions

220

actions = client.scheduled_actions.list()

221

222

print(f"Found {len(actions.value)} scheduled actions:")

223

for action in actions.value:

224

print(f" Name: {action.name}")

225

print(f" Display Name: {action.display_name}")

226

print(f" Kind: {action.kind}")

227

print(f" Status: {action.status}")

228

print(f" Frequency: {action.schedule.frequency}")

229

print(f" Next Run: {action.schedule.start_date}")

230

print(" ---")

231

232

# List actions for specific subscription

233

scope = "/subscriptions/{subscription-id}"

234

scoped_actions = client.scheduled_actions.list_by_scope(scope)

235

236

print(f"\nSubscription actions ({len(scoped_actions.value)}):")

237

for action in scoped_actions.value:

238

print(f" {action.name}: {action.status}")

239

```

240

241

### Create Daily Cost Insight Alert

242

243

```python

244

# Daily insight alert for cost anomalies

245

daily_notification = NotificationProperties(

246

to=["cost-alerts@company.com"],

247

subject="Daily Cost Insights - Anomaly Detection",

248

message="Daily cost analysis has detected potential anomalies in your Azure spending."

249

)

250

251

daily_schedule = ScheduleProperties(

252

frequency=ScheduleFrequency.DAILY,

253

hour_of_day=8,

254

start_date="2024-01-01T00:00:00Z"

255

)

256

257

insight_alert = ScheduledAction(

258

kind=ScheduledActionKind.INSIGHT_ALERT,

259

display_name="Daily Cost Insights",

260

notification=daily_notification,

261

schedule=daily_schedule,

262

scope=scope,

263

status=ScheduledActionStatus.ENABLED

264

)

265

266

daily_action = client.scheduled_actions.create_or_update(

267

name="daily-cost-insights",

268

scheduled_action=insight_alert

269

)

270

```

271

272

### Execute Scheduled Action Immediately

273

274

```python

275

# Run a scheduled action on-demand

276

print("Executing budget alert immediately...")

277

client.scheduled_actions.run("weekly-budget-alert")

278

print("Action executed successfully")

279

280

# Run scoped action

281

client.scheduled_actions.run_by_scope(scope, "daily-cost-insights")

282

print("Scoped action executed successfully")

283

```

284

285

### Check Name Availability

286

287

```python

288

from azure.mgmt.costmanagement.models import CheckNameAvailabilityRequest

289

290

# Check if action name is available

291

availability_request = CheckNameAvailabilityRequest(

292

name="new-budget-alert",

293

type="Microsoft.CostManagement/scheduledActions"

294

)

295

296

availability = client.scheduled_actions.check_name_availability(availability_request)

297

298

if availability.name_available:

299

print(f"Name '{availability_request.name}' is available")

300

else:

301

print(f"Name not available. Reason: {availability.reason}")

302

print(f"Message: {availability.message}")

303

```

304

305

### Update Existing Scheduled Action

306

307

```python

308

# Get existing action

309

existing_action = client.scheduled_actions.get("weekly-budget-alert")

310

311

# Update notification recipients

312

existing_action.notification.to.append("ceo@company.com")

313

314

# Update schedule frequency to daily

315

existing_action.schedule.frequency = ScheduleFrequency.DAILY

316

existing_action.schedule.hour_of_day = 7

317

318

# Update the action

319

updated_action = client.scheduled_actions.create_or_update(

320

name="weekly-budget-alert",

321

scheduled_action=existing_action

322

)

323

324

print(f"Updated action: {updated_action.display_name}")

325

```

326

327

## Data Models

328

329

### Scheduled Action Models

330

331

```python { .api }

332

class ScheduledAction:

333

id: str

334

name: str

335

type: str

336

kind: ScheduledActionKind

337

display_name: str

338

file_destination: FileDestination

339

notification: NotificationProperties

340

schedule: ScheduleProperties

341

scope: str

342

status: ScheduledActionStatus

343

view_id: str

344

345

class ScheduleProperties:

346

frequency: ScheduleFrequency

347

hour_of_day: int

348

days_of_week: List[DaysOfWeek]

349

weeks_of_month: List[WeeksOfMonth]

350

day_of_month: int

351

start_date: str

352

end_date: str

353

354

class NotificationProperties:

355

to: List[str]

356

language: str

357

message: str

358

regional_format: str

359

subject: str

360

361

class ScheduledActionListResult:

362

value: List[ScheduledAction]

363

next_link: str

364

365

class CheckNameAvailabilityRequest:

366

def __init__(self, name: str, type: str): ...

367

368

class CheckNameAvailabilityResponse:

369

name_available: bool

370

reason: str

371

message: str

372

373

class FileDestination:

374

file_formats: List[str]

375

```

376

377

## Scheduled Action Enumerations

378

379

```python { .api }

380

class ScheduledActionKind(str, Enum):

381

EMAIL = "Email"

382

INSIGHT_ALERT = "InsightAlert"

383

384

class ScheduledActionStatus(str, Enum):

385

ENABLED = "Enabled"

386

DISABLED = "Disabled"

387

EXPIRED = "Expired"

388

389

class ScheduleFrequency(str, Enum):

390

DAILY = "Daily"

391

WEEKLY = "Weekly"

392

MONTHLY = "Monthly"

393

394

class DaysOfWeek(str, Enum):

395

MONDAY = "Monday"

396

TUESDAY = "Tuesday"

397

WEDNESDAY = "Wednesday"

398

THURSDAY = "Thursday"

399

FRIDAY = "Friday"

400

SATURDAY = "Saturday"

401

SUNDAY = "Sunday"

402

403

class WeeksOfMonth(str, Enum):

404

FIRST = "First"

405

SECOND = "Second"

406

THIRD = "Third"

407

FOURTH = "Fourth"

408

LAST = "Last"

409

410

class CheckNameAvailabilityReason(str, Enum):

411

INVALID = "Invalid"

412

ALREADY_EXISTS = "AlreadyExists"

413

```

414

415

This module provides comprehensive scheduled action capabilities for automating cost management workflows, notifications, and proactive cost monitoring across Azure resources and scopes.