or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

client-setup.mdimmediate-operations.mdindex.mdmodels-types.mdoperation-management.mdscheduled-operations.md

scheduled-operations.mddocs/

0

# Scheduled Operations

1

2

Submit VM operations to be executed at future scheduled times with deadline-based execution control, optimization preferences, and retry policies. These operations allow you to plan VM lifecycle changes in advance.

3

4

## Capabilities

5

6

### Submit Deallocate Operation

7

8

Schedule virtual machines to be deallocated at a specified future time, releasing compute resources while preserving storage.

9

10

```python { .api }

11

def virtual_machines_submit_deallocate(

12

self,

13

locationparameter: str,

14

request_body: Union[SubmitDeallocateRequest, JSON, IO[bytes]],

15

**kwargs: Any

16

) -> DeallocateResourceOperationResponse:

17

"""

18

Submit deallocate operation for VMs to be executed at scheduled time.

19

20

Parameters:

21

- locationparameter: Azure region where operation will be executed (required)

22

- request_body: Deallocate request with schedule and execution parameters (required)

23

24

Returns:

25

Response containing operation ID and status information

26

"""

27

```

28

29

**Usage Example:**

30

31

```python

32

from azure.mgmt.computeschedule.models import (

33

SubmitDeallocateRequest,

34

Schedule,

35

ExecutionParameters,

36

Resources,

37

DeadlineType

38

)

39

40

# Define when to execute the operation

41

schedule = Schedule(

42

deadline_type=DeadlineType.INITIATE_AT,

43

deadline="2024-01-15T10:00:00Z",

44

timezone="UTC"

45

)

46

47

# Define which VMs and how to execute

48

execution_params = ExecutionParameters(

49

resources=Resources(

50

ids=[

51

"/subscriptions/{subscription_id}/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/vm1",

52

"/subscriptions/{subscription_id}/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/vm2"

53

]

54

)

55

)

56

57

# Create the request

58

request = SubmitDeallocateRequest(

59

schedule=schedule,

60

execution_parameters=execution_params

61

)

62

63

# Submit the scheduled operation

64

response = client.scheduled_actions.virtual_machines_submit_deallocate(

65

locationparameter="eastus",

66

request_body=request

67

)

68

69

print(f"Deallocate operation scheduled with ID: {response.operation_id}")

70

```

71

72

### Submit Hibernate Operation

73

74

Schedule virtual machines to be hibernated at a specified future time, preserving memory state while stopping compute billing.

75

76

```python { .api }

77

def virtual_machines_submit_hibernate(

78

self,

79

locationparameter: str,

80

request_body: Union[SubmitHibernateRequest, JSON, IO[bytes]],

81

**kwargs: Any

82

) -> HibernateResourceOperationResponse:

83

"""

84

Submit hibernate operation for VMs to be executed at scheduled time.

85

86

Parameters:

87

- locationparameter: Azure region where operation will be executed (required)

88

- request_body: Hibernate request with schedule and execution parameters (required)

89

90

Returns:

91

Response containing operation ID and status information

92

"""

93

```

94

95

**Usage Example:**

96

97

```python

98

from azure.mgmt.computeschedule.models import (

99

SubmitHibernateRequest,

100

Schedule,

101

ExecutionParameters,

102

Resources,

103

DeadlineType,

104

OptimizationPreference

105

)

106

107

# Schedule for completion by deadline

108

schedule = Schedule(

109

deadline_type=DeadlineType.COMPLETE_BY,

110

deadline="2024-01-15T22:00:00Z",

111

timezone="UTC"

112

)

113

114

# Configure execution with optimization

115

execution_params = ExecutionParameters(

116

resources=Resources(

117

ids=["/subscriptions/{subscription_id}/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/hibernateVM"]

118

),

119

optimization_preference=OptimizationPreference.COST

120

)

121

122

request = SubmitHibernateRequest(

123

schedule=schedule,

124

execution_parameters=execution_params

125

)

126

127

response = client.scheduled_actions.virtual_machines_submit_hibernate(

128

locationparameter="westus2",

129

request_body=request

130

)

131

132

print(f"Hibernate operation scheduled with ID: {response.operation_id}")

133

```

134

135

### Submit Start Operation

136

137

Schedule virtual machines to be started at a specified future time, bringing stopped or deallocated VMs back online.

138

139

```python { .api }

140

def virtual_machines_submit_start(

141

self,

142

locationparameter: str,

143

request_body: Union[SubmitStartRequest, JSON, IO[bytes]],

144

**kwargs: Any

145

) -> StartResourceOperationResponse:

146

"""

147

Submit start operation for VMs to be executed at scheduled time.

148

149

Parameters:

150

- locationparameter: Azure region where operation will be executed (required)

151

- request_body: Start request with schedule and execution parameters (required)

152

153

Returns:

154

Response containing operation ID and status information

155

"""

156

```

157

158

**Usage Example:**

159

160

```python

161

from azure.mgmt.computeschedule.models import (

162

SubmitStartRequest,

163

Schedule,

164

ExecutionParameters,

165

Resources,

166

RetryPolicy,

167

DeadlineType

168

)

169

170

# Schedule start for Monday morning

171

schedule = Schedule(

172

deadline_type=DeadlineType.INITIATE_AT,

173

deadline="2024-01-15T08:00:00Z",

174

timezone="UTC"

175

)

176

177

# Configure with retry policy

178

retry_policy = RetryPolicy(

179

retry_count=3,

180

retry_window_in_minutes=30

181

)

182

183

execution_params = ExecutionParameters(

184

resources=Resources(

185

ids=[

186

"/subscriptions/{subscription_id}/resourceGroups/prodRG/providers/Microsoft.Compute/virtualMachines/webServer1",

187

"/subscriptions/{subscription_id}/resourceGroups/prodRG/providers/Microsoft.Compute/virtualMachines/webServer2"

188

]

189

),

190

retry_policy=retry_policy

191

)

192

193

request = SubmitStartRequest(

194

schedule=schedule,

195

execution_parameters=execution_params

196

)

197

198

response = client.scheduled_actions.virtual_machines_submit_start(

199

locationparameter="eastus",

200

request_body=request

201

)

202

203

print(f"Start operation scheduled with ID: {response.operation_id}")

204

```

205

206

## Schedule Configuration

207

208

### Schedule Types

209

210

Configure when operations should be executed using deadline types:

211

212

- **INITIATE_AT**: Begin operation at specified deadline time

213

- **COMPLETE_BY**: Ensure operation completes by specified deadline time

214

- **UNKNOWN**: Default/unspecified deadline type

215

216

### Time Zone Support

217

218

Specify time zones for accurate scheduling across regions:

219

220

```python

221

# UTC timezone (recommended for consistency)

222

schedule = Schedule(

223

deadline_type=DeadlineType.INITIATE_AT,

224

deadline="2024-01-15T10:00:00Z",

225

timezone="UTC"

226

)

227

228

# Regional timezone

229

schedule = Schedule(

230

deadline_type=DeadlineType.INITIATE_AT,

231

deadline="2024-01-15T10:00:00",

232

timezone="America/New_York"

233

)

234

```

235

236

### Execution Parameters

237

238

Configure how operations are executed:

239

240

```python

241

from azure.mgmt.computeschedule.models import (

242

ExecutionParameters,

243

Resources,

244

OptimizationPreference,

245

RetryPolicy

246

)

247

248

execution_params = ExecutionParameters(

249

# Target VMs by resource ID

250

resources=Resources(

251

ids=[

252

"/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vm}"

253

]

254

),

255

# Optimize for cost or speed

256

optimization_preference=OptimizationPreference.COST,

257

# Configure retry behavior

258

retry_policy=RetryPolicy(

259

retry_count=3,

260

retry_window_in_minutes=30

261

)

262

)

263

```