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

reports.mddocs/

0

# Report Generation

1

2

Generate detailed cost reports including cost details reports, reservation details, and comprehensive billing reports with custom time periods and formats. Support for long-running operations with status monitoring and result retrieval for large-scale cost analysis and reporting workflows.

3

4

## Capabilities

5

6

### Cost Details Report Generation

7

8

Generate detailed cost reports with comprehensive cost breakdown and analysis for specified scopes and time periods.

9

10

```python { .api }

11

def begin_create_operation(

12

scope: str,

13

parameters: GenerateCostDetailsReportRequestDefinition

14

) -> LROPoller[CostDetailsOperationResults]:

15

"""

16

Start long-running cost details report generation.

17

18

Args:

19

scope (str): The scope for the report generation

20

parameters (GenerateCostDetailsReportRequestDefinition): Report configuration

21

22

Returns:

23

LROPoller[CostDetailsOperationResults]: Long-running operation poller for cost details

24

"""

25

```

26

27

### Detailed Cost Report Generation

28

29

Generate comprehensive detailed cost reports with advanced configuration options and custom metrics.

30

31

```python { .api }

32

def begin_create_operation(

33

scope: str,

34

parameters: GenerateDetailedCostReportDefinition

35

) -> LROPoller[GenerateDetailedCostReportOperationResult]:

36

"""

37

Start long-running detailed cost report generation.

38

39

Args:

40

scope (str): The scope for the report generation

41

parameters (GenerateDetailedCostReportDefinition): Detailed report configuration

42

43

Returns:

44

LROPoller[GenerateDetailedCostReportOperationResult]: Long-running operation poller

45

"""

46

```

47

48

### Detailed Cost Report Operation Management

49

50

Monitor and retrieve results from detailed cost report generation operations.

51

52

```python { .api }

53

def get(operation_id: str, scope: str) -> GenerateDetailedCostReportOperationResult:

54

"""

55

Get detailed cost report operation results by ID.

56

57

Args:

58

operation_id (str): The operation ID from the long-running operation

59

scope (str): The scope of the operation

60

61

Returns:

62

GenerateDetailedCostReportOperationResult: Report generation results and download URLs

63

"""

64

```

65

66

```python { .api }

67

def get(operation_id: str, scope: str) -> GenerateDetailedCostReportOperationStatuses:

68

"""

69

Get detailed cost report operation status by ID.

70

71

Args:

72

operation_id (str): The operation ID from the long-running operation

73

scope (str): The scope of the operation

74

75

Returns:

76

GenerateDetailedCostReportOperationStatuses: Current status of the report generation

77

"""

78

```

79

80

### Reservation Details Report Generation

81

82

Generate specialized reports for Azure Reserved Instances with detailed usage and cost breakdown.

83

84

```python { .api }

85

def begin_by_billing_account_id(

86

billing_account_id: str,

87

start_date: str,

88

end_date: str

89

) -> LROPoller[ReservationDetailsOperationResults]:

90

"""

91

Generate reservation details report by billing account.

92

93

Args:

94

billing_account_id (str): The billing account ID

95

start_date (str): Report start date (YYYY-MM-DD format)

96

end_date (str): Report end date (YYYY-MM-DD format)

97

98

Returns:

99

LROPoller[ReservationDetailsOperationResults]: Long-running operation for reservation report

100

"""

101

102

def begin_by_billing_profile_id(

103

billing_account_id: str,

104

billing_profile_id: str,

105

start_date: str,

106

end_date: str

107

) -> LROPoller[ReservationDetailsOperationResults]:

108

"""

109

Generate reservation details report by billing profile.

110

111

Args:

112

billing_account_id (str): The billing account ID

113

billing_profile_id (str): The billing profile ID

114

start_date (str): Report start date (YYYY-MM-DD format)

115

end_date (str): Report end date (YYYY-MM-DD format)

116

117

Returns:

118

LROPoller[ReservationDetailsOperationResults]: Long-running operation for reservation report

119

"""

120

```

121

122

## Usage Examples

123

124

### Generate Basic Cost Details Report

125

126

```python

127

from azure.mgmt.costmanagement.models import (

128

GenerateCostDetailsReportRequestDefinition,

129

CostDetailsTimePeriod,

130

CostDetailsMetricType,

131

CostDetailsDataFormat

132

)

133

134

# Configure cost details report

135

report_config = GenerateCostDetailsReportRequestDefinition(

136

metric=CostDetailsMetricType.ACTUAL_COST,

137

time_period=CostDetailsTimePeriod(

138

start="2024-01-01",

139

end="2024-01-31"

140

),

141

billing_period=None

142

)

143

144

# Start report generation

145

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

146

operation = client.generate_cost_details_report.begin_create_operation(

147

scope=scope,

148

parameters=report_config

149

)

150

151

print("Cost details report generation started...")

152

print(f"Operation ID: {operation.result().id}")

153

154

# Wait for completion

155

result = operation.result()

156

print(f"Report completed. Status: {result.status}")

157

158

if result.download_url:

159

print(f"Download URL: {result.download_url}")

160

```

161

162

### Generate Detailed Cost Report with Custom Configuration

163

164

```python

165

from azure.mgmt.costmanagement.models import (

166

GenerateDetailedCostReportDefinition,

167

ReportConfigTimePeriod,

168

GenerateDetailedCostReportTimePeriod,

169

GenerateDetailedCostReportMetricType,

170

ReportTimeframeType

171

)

172

173

# Configure detailed report with custom metrics

174

detailed_config = GenerateDetailedCostReportDefinition(

175

metric=GenerateDetailedCostReportMetricType.AMORTIZED_COST,

176

time_period=GenerateDetailedCostReportTimePeriod(

177

start="2024-01-01",

178

end="2024-03-31"

179

),

180

billing_period=None,

181

custom_filters=None

182

)

183

184

# Generate detailed report

185

detailed_operation = client.generate_detailed_cost_report.begin_create_operation(

186

scope=scope,

187

parameters=detailed_config

188

)

189

190

print("Detailed cost report generation started...")

191

192

# Monitor progress

193

while not detailed_operation.done():

194

print("Report generation in progress...")

195

time.sleep(30) # Wait 30 seconds before checking again

196

197

detailed_result = detailed_operation.result()

198

print(f"Detailed report completed: {detailed_result.status}")

199

200

# Get download information

201

if hasattr(detailed_result, 'blob_info') and detailed_result.blob_info:

202

print(f"Report size: {detailed_result.blob_info.blob_count} blobs")

203

for i, blob in enumerate(detailed_result.blob_info.blobs):

204

print(f" Blob {i+1}: {blob.name}")

205

```

206

207

### Monitor Report Generation Status

208

209

```python

210

# Check operation status

211

operation_id = "report-op-123456"

212

status = client.generate_detailed_cost_report_operation_status.get(

213

operation_id=operation_id,

214

scope=scope

215

)

216

217

print(f"Report Operation Status:")

218

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

219

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

220

print(f" Start Time: {status.start_time}")

221

222

if status.status == "Completed":

223

# Get results when completed

224

results = client.generate_detailed_cost_report_operation_results.get(

225

operation_id=operation_id,

226

scope=scope

227

)

228

229

print(f"Report Results:")

230

print(f" Manifest Version: {results.manifest_version}")

231

print(f" Data Format: {results.data_format}")

232

233

if results.blob_info:

234

print(f" Number of Blobs: {len(results.blob_info.blobs)}")

235

for blob in results.blob_info.blobs:

236

print(f" Blob: {blob.name} ({blob.size} bytes)")

237

238

elif status.status == "Failed":

239

print(f" Error: {status.error}")

240

```

241

242

### Generate Reservation Details Report

243

244

```python

245

import time

246

from datetime import datetime, timedelta

247

248

# Generate reservation report for last month

249

end_date = datetime.now().strftime("%Y-%m-%d")

250

start_date = (datetime.now() - timedelta(days=30)).strftime("%Y-%m-%d")

251

252

billing_account_id = "12345678"

253

254

# Start reservation report generation

255

reservation_operation = client.generate_reservation_details_report.begin_by_billing_account_id(

256

billing_account_id=billing_account_id,

257

start_date=start_date,

258

end_date=end_date

259

)

260

261

print(f"Reservation details report generation started for period {start_date} to {end_date}")

262

263

# Wait for completion with progress updates

264

while not reservation_operation.done():

265

print("Generating reservation report...")

266

time.sleep(45)

267

268

reservation_result = reservation_operation.result()

269

print(f"Reservation report completed: {reservation_result.status}")

270

271

if hasattr(reservation_result, 'download_url') and reservation_result.download_url:

272

print(f"Reservation report download URL: {reservation_result.download_url}")

273

```

274

275

### Generate Report by Billing Profile

276

277

```python

278

# Generate reservation report for specific billing profile

279

billing_profile_id = "bp-67890"

280

281

profile_operation = client.generate_reservation_details_report.begin_by_billing_profile_id(

282

billing_account_id=billing_account_id,

283

billing_profile_id=billing_profile_id,

284

start_date=start_date,

285

end_date=end_date

286

)

287

288

print("Generating billing profile reservation report...")

289

profile_result = profile_operation.result()

290

291

print(f"Billing profile report status: {profile_result.status}")

292

```

293

294

### Batch Report Generation

295

296

```python

297

# Generate multiple reports concurrently

298

import concurrent.futures

299

300

def generate_monthly_reports(months):

301

"""Generate reports for multiple months concurrently"""

302

operations = []

303

304

for month in months:

305

start_date = f"2024-{month:02d}-01"

306

if month == 12:

307

end_date = f"2024-{month:02d}-31"

308

else:

309

end_date = f"2024-{month:02d}-28" # Simplified for example

310

311

config = GenerateCostDetailsReportRequestDefinition(

312

metric=CostDetailsMetricType.ACTUAL_COST,

313

time_period=CostDetailsTimePeriod(start=start_date, end=end_date)

314

)

315

316

operation = client.generate_cost_details_report.begin_create_operation(

317

scope=scope,

318

parameters=config

319

)

320

operations.append((month, operation))

321

322

# Wait for all operations to complete

323

results = {}

324

for month, operation in operations:

325

result = operation.result()

326

results[month] = result

327

print(f"Month {month} report: {result.status}")

328

329

return results

330

331

# Generate reports for Q1

332

monthly_results = generate_monthly_reports([1, 2, 3])

333

```

334

335

## Data Models

336

337

### Cost Details Report Models

338

339

```python { .api }

340

class GenerateCostDetailsReportRequestDefinition:

341

metric: CostDetailsMetricType

342

time_period: CostDetailsTimePeriod

343

billing_period: str

344

345

class CostDetailsTimePeriod:

346

start: str

347

end: str

348

349

class CostDetailsOperationResults:

350

id: str

351

name: str

352

type: str

353

status: str

354

download_url: str

355

blob_info: BlobInfo

356

error: ErrorDetails

357

```

358

359

### Detailed Cost Report Models

360

361

```python { .api }

362

class GenerateDetailedCostReportDefinition:

363

metric: GenerateDetailedCostReportMetricType

364

time_period: GenerateDetailedCostReportTimePeriod

365

billing_period: str

366

custom_filters: List[str]

367

368

class GenerateDetailedCostReportTimePeriod:

369

start: str

370

end: str

371

372

class GenerateDetailedCostReportOperationResult:

373

id: str

374

name: str

375

type: str

376

status: ReportOperationStatusType

377

manifest_version: str

378

data_format: str

379

blob_info: BlobInfo

380

error: ErrorDetails

381

382

class GenerateDetailedCostReportOperationStatuses:

383

id: str

384

name: str

385

type: str

386

status: ReportOperationStatusType

387

start_time: str

388

end_time: str

389

error: ErrorDetails

390

```

391

392

### Reservation Report Models

393

394

```python { .api }

395

class ReservationDetailsOperationResults:

396

id: str

397

name: str

398

type: str

399

status: str

400

download_url: DownloadURL

401

error: ErrorDetails

402

403

class DownloadURL:

404

expires_on: str

405

url: str

406

```

407

408

### Common Report Models

409

410

```python { .api }

411

class BlobInfo:

412

blob_count: int

413

blobs: List[BlobDetails]

414

415

class BlobDetails:

416

name: str

417

size: int

418

url: str

419

420

class ErrorDetails:

421

code: str

422

message: str

423

details: List[ErrorDetails]

424

```

425

426

## Report Enumerations

427

428

```python { .api }

429

class CostDetailsMetricType(str, Enum):

430

ACTUAL_COST = "ActualCost"

431

AMORTIZED_COST = "AmortizedCost"

432

433

class GenerateDetailedCostReportMetricType(str, Enum):

434

ACTUAL_COST = "ActualCost"

435

AMORTIZED_COST = "AmortizedCost"

436

437

class CostDetailsDataFormat(str, Enum):

438

CSV = "Csv"

439

440

class ReportOperationStatusType(str, Enum):

441

RUNNING = "Running"

442

COMPLETED = "Completed"

443

FAILED = "Failed"

444

TIMED_OUT = "TimedOut"

445

446

class CostDetailsStatusType(str, Enum):

447

COMPLETED = "Completed"

448

DATA_NOT_AVAILABLE = "DataNotAvailable"

449

FAILED = "Failed"

450

IN_PROGRESS = "InProgress"

451

QUEUED = "Queued"

452

TIMED_OUT = "TimedOut"

453

454

class ReservationReportSchema(str, Enum):

455

INSTANCE_FLEXIBILITY_RATIO = "InstanceFlexibilityRatio"

456

INSTANCE_FLEXIBILITY_GROUP = "InstanceFlexibilityGroup"

457

```

458

459

This module provides comprehensive report generation capabilities for detailed cost analysis, reservation tracking, and large-scale billing data export with support for long-running operations and multiple output formats.