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

client-setup.mddocs/

0

# Client Setup and Configuration

1

2

Initialize and configure the Azure ComputeSchedule management client with proper authentication, subscription targeting, and optional custom settings.

3

4

## Capabilities

5

6

### Synchronous Client Initialization

7

8

Create a synchronous ComputeSchedule management client for standard operations.

9

10

```python { .api }

11

class ComputeScheduleMgmtClient:

12

def __init__(

13

self,

14

credential: TokenCredential,

15

subscription_id: str,

16

base_url: Optional[str] = None,

17

**kwargs: Any

18

) -> None:

19

"""

20

Initialize ComputeSchedule management client.

21

22

Parameters:

23

- credential: TokenCredential for authentication (required)

24

- subscription_id: Azure subscription ID in UUID format (required)

25

- base_url: Custom service host URL (optional)

26

- api_version: API version override (keyword-only, default: "2025-05-01")

27

"""

28

```

29

30

**Usage Example:**

31

32

```python

33

from azure.mgmt.computeschedule import ComputeScheduleMgmtClient

34

from azure.identity import DefaultAzureCredential

35

import os

36

37

# Standard initialization with default Azure credentials

38

credential = DefaultAzureCredential()

39

subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")

40

client = ComputeScheduleMgmtClient(credential, subscription_id)

41

42

# Custom configuration with specific API version

43

client = ComputeScheduleMgmtClient(

44

credential=credential,

45

subscription_id=subscription_id,

46

api_version="2025-05-01"

47

)

48

```

49

50

### Asynchronous Client Initialization

51

52

Create an asynchronous ComputeSchedule management client for async/await operations.

53

54

```python { .api }

55

# From azure.mgmt.computeschedule.aio

56

class ComputeScheduleMgmtClient:

57

def __init__(

58

self,

59

credential: AsyncTokenCredential,

60

subscription_id: str,

61

base_url: Optional[str] = None,

62

**kwargs: Any

63

) -> None:

64

"""

65

Initialize async ComputeSchedule management client.

66

67

Same parameters as synchronous client but supports async operations.

68

"""

69

```

70

71

**Usage Example:**

72

73

```python

74

from azure.mgmt.computeschedule.aio import ComputeScheduleMgmtClient

75

from azure.identity.aio import DefaultAzureCredential

76

import asyncio

77

78

async def main():

79

credential = DefaultAzureCredential()

80

subscription_id = "your-subscription-id"

81

82

async with ComputeScheduleMgmtClient(credential, subscription_id) as client:

83

# Use client for async operations

84

operations = await client.operations.list()

85

async for operation in operations:

86

print(f"Operation: {operation.name}")

87

88

asyncio.run(main())

89

```

90

91

### Client Properties and Methods

92

93

Access operation interfaces and utility methods through the initialized client.

94

95

```python { .api }

96

class ComputeScheduleMgmtClient:

97

@property

98

def operations(self) -> Operations:

99

"""General operations interface for provider operations."""

100

101

@property

102

def scheduled_actions(self) -> ScheduledActionsOperations:

103

"""VM scheduling operations interface."""

104

105

def send_request(

106

self,

107

request: HttpRequest,

108

*,

109

stream: bool = False,

110

**kwargs: Any

111

) -> HttpResponse:

112

"""

113

Send custom HTTP request through client pipeline.

114

115

Parameters:

116

- request: HTTP request to send (required)

117

- stream: Whether to stream response payload (keyword-only, default: False)

118

119

Returns:

120

HTTP response without error handling

121

"""

122

123

def close(self) -> None:

124

"""Close client connections and cleanup resources."""

125

126

def __enter__(self) -> Self:

127

"""Context manager entry."""

128

129

def __exit__(self, *exc_details: Any) -> None:

130

"""Context manager exit with cleanup."""

131

```

132

133

### Authentication Configuration

134

135

Set up Azure Active Directory authentication using environment variables or credential objects.

136

137

**Environment Variables:**

138

```bash

139

export AZURE_CLIENT_ID="your-client-id"

140

export AZURE_TENANT_ID="your-tenant-id"

141

export AZURE_CLIENT_SECRET="your-client-secret"

142

export AZURE_SUBSCRIPTION_ID="your-subscription-id"

143

```

144

145

**Authentication Examples:**

146

147

```python

148

from azure.identity import (

149

DefaultAzureCredential,

150

ClientSecretCredential,

151

ManagedIdentityCredential

152

)

153

154

# Default credential chain (recommended)

155

credential = DefaultAzureCredential()

156

157

# Specific service principal

158

credential = ClientSecretCredential(

159

tenant_id="your-tenant-id",

160

client_id="your-client-id",

161

client_secret="your-client-secret"

162

)

163

164

# Managed identity (for Azure resources)

165

credential = ManagedIdentityCredential()

166

167

# Initialize client with chosen credential

168

client = ComputeScheduleMgmtClient(credential, subscription_id)

169

```

170

171

### Context Manager Usage

172

173

Use the client as a context manager for automatic resource cleanup.

174

175

```python

176

from azure.mgmt.computeschedule import ComputeScheduleMgmtClient

177

from azure.identity import DefaultAzureCredential

178

179

subscription_id = "your-subscription-id"

180

credential = DefaultAzureCredential()

181

182

# Automatic cleanup with context manager

183

with ComputeScheduleMgmtClient(credential, subscription_id) as client:

184

# Client operations

185

response = client.scheduled_actions.virtual_machines_submit_deallocate(

186

locationparameter="eastus",

187

request_body=request

188

)

189

print(f"Operation ID: {response.operation_id}")

190

# Client automatically closed here

191

```