or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

blob-storage.mdfile-storage.mdindex.mdpolicy-management.mdqueue-storage.mdsecurity-access.mdstorage-accounts.mdstorage-tasks.mdtable-storage.mdutilities.md

blob-storage.mddocs/

0

# Blob Storage Management

1

2

Management of Azure Blob storage services including blob service configuration, container management, and blob inventory policies. Blob storage provides scalable object storage for unstructured data.

3

4

## Capabilities

5

6

### Blob Service Configuration

7

8

Configure blob service properties including CORS rules, delete retention policies, and versioning settings.

9

10

```python { .api }

11

class BlobServicesOperations:

12

def get_service_properties(

13

self,

14

resource_group_name: str,

15

account_name: str

16

) -> BlobServiceProperties:

17

"""

18

Gets the properties of a storage account's Blob service.

19

20

Parameters:

21

- resource_group_name: Name of the resource group

22

- account_name: Name of the storage account

23

24

Returns:

25

BlobServiceProperties with current configuration

26

"""

27

28

def set_service_properties(

29

self,

30

resource_group_name: str,

31

account_name: str,

32

parameters: BlobServiceProperties

33

) -> BlobServiceProperties:

34

"""

35

Sets the properties of a storage account's Blob service.

36

37

Parameters:

38

- resource_group_name: Name of the resource group

39

- account_name: Name of the storage account

40

- parameters: Blob service properties to set

41

42

Returns:

43

Updated BlobServiceProperties

44

"""

45

46

def list(

47

self,

48

resource_group_name: str,

49

account_name: str

50

) -> BlobServiceItems:

51

"""

52

List blob services for a storage account.

53

54

Parameters:

55

- resource_group_name: Name of the resource group

56

- account_name: Name of the storage account

57

58

Returns:

59

BlobServiceItems containing the blob service

60

"""

61

```

62

63

Usage example:

64

65

```python

66

from azure.mgmt.storage.models import (

67

BlobServiceProperties, DeleteRetentionPolicy,

68

RestorePolicyProperties, CorsRules, CorsRule

69

)

70

71

# Get current blob service properties

72

blob_service = client.blob_services.get_service_properties(

73

resource_group_name="my-resource-group",

74

account_name="mystorageaccount123"

75

)

76

77

# Configure blob service with delete retention and CORS

78

cors_rule = CorsRule(

79

allowed_origins=["https://example.com"],

80

allowed_methods=["GET", "POST"],

81

allowed_headers=["*"],

82

exposed_headers=["*"],

83

max_age_in_seconds=3600

84

)

85

86

blob_properties = BlobServiceProperties(

87

properties=BlobServicePropertiesProperties(

88

delete_retention_policy=DeleteRetentionPolicy(

89

enabled=True,

90

days=30

91

),

92

restore_policy=RestorePolicyProperties(

93

enabled=True,

94

days=7,

95

minimum_days_to_retain=1

96

),

97

cors=CorsRules(cors_rules=[cors_rule]),

98

is_versioning_enabled=True,

99

change_feed=ChangeFeed(enabled=True, retention_in_days=90)

100

)

101

)

102

103

updated_service = client.blob_services.set_service_properties(

104

resource_group_name="my-resource-group",

105

account_name="mystorageaccount123",

106

parameters=blob_properties

107

)

108

```

109

110

### Blob Container Management

111

112

Create, manage, and configure blob containers with access policies, metadata, and lease operations.

113

114

```python { .api }

115

class BlobContainersOperations:

116

def create(

117

self,

118

resource_group_name: str,

119

account_name: str,

120

container_name: str,

121

blob_container: BlobContainer

122

) -> BlobContainer:

123

"""

124

Creates a new container under the specified account.

125

126

Parameters:

127

- resource_group_name: Name of the resource group

128

- account_name: Name of the storage account

129

- container_name: Name of the blob container (3-63 chars, lowercase)

130

- blob_container: Container properties and configuration

131

132

Returns:

133

Created BlobContainer

134

"""

135

136

def update(

137

self,

138

resource_group_name: str,

139

account_name: str,

140

container_name: str,

141

blob_container: BlobContainer

142

) -> BlobContainer:

143

"""

144

Updates container properties or metadata.

145

146

Parameters:

147

- resource_group_name: Name of the resource group

148

- account_name: Name of the storage account

149

- container_name: Name of the blob container

150

- blob_container: Updated container properties

151

152

Returns:

153

Updated BlobContainer

154

"""

155

156

def get(

157

self,

158

resource_group_name: str,

159

account_name: str,

160

container_name: str

161

) -> BlobContainer:

162

"""

163

Gets properties of a specified container.

164

165

Parameters:

166

- resource_group_name: Name of the resource group

167

- account_name: Name of the storage account

168

- container_name: Name of the blob container

169

170

Returns:

171

BlobContainer with properties

172

"""

173

174

def delete(

175

self,

176

resource_group_name: str,

177

account_name: str,

178

container_name: str

179

) -> None:

180

"""

181

Deletes the specified container and any blobs it contains.

182

183

Parameters:

184

- resource_group_name: Name of the resource group

185

- account_name: Name of the storage account

186

- container_name: Name of the blob container

187

"""

188

189

def list(

190

self,

191

resource_group_name: str,

192

account_name: str,

193

maxpagesize: Optional[str] = None,

194

filter: Optional[str] = None,

195

include: Optional[ListContainersInclude] = None

196

) -> ItemPaged[ListContainerItem]:

197

"""

198

Lists all containers in a storage account.

199

200

Parameters:

201

- resource_group_name: Name of the resource group

202

- account_name: Name of the storage account

203

- maxpagesize: Maximum number of results per page

204

- filter: OData filter expression

205

- include: Include additional properties (deleted containers, metadata)

206

207

Returns:

208

Paginated list of ListContainerItem objects

209

"""

210

```

211

212

Usage example:

213

214

```python

215

from azure.mgmt.storage.models import (

216

BlobContainer, PublicAccess, BlobContainerProperties

217

)

218

219

# Create a private container

220

container = BlobContainer(

221

properties=BlobContainerProperties(

222

public_access=PublicAccess.NONE,

223

metadata={"Department": "Finance", "Project": "Reports"}

224

)

225

)

226

227

created_container = client.blob_containers.create(

228

resource_group_name="my-resource-group",

229

account_name="mystorageaccount123",

230

container_name="private-documents",

231

blob_container=container

232

)

233

234

# Create a public container for blob access

235

public_container = BlobContainer(

236

properties=BlobContainerProperties(

237

public_access=PublicAccess.BLOB,

238

metadata={"Type": "Public", "Purpose": "Static Content"}

239

)

240

)

241

242

client.blob_containers.create(

243

resource_group_name="my-resource-group",

244

account_name="mystorageaccount123",

245

container_name="public-assets",

246

blob_container=public_container

247

)

248

249

# List all containers

250

containers = list(client.blob_containers.list(

251

resource_group_name="my-resource-group",

252

account_name="mystorageaccount123"

253

))

254

255

for container in containers:

256

print(f"Container: {container.name}, Public Access: {container.public_access}")

257

```

258

259

### Container Access Policies

260

261

Manage stored access policies for fine-grained container permissions.

262

263

```python { .api }

264

def set_legal_hold(

265

self,

266

resource_group_name: str,

267

account_name: str,

268

container_name: str,

269

legal_hold: LegalHold

270

) -> LegalHold:

271

"""

272

Sets legal hold tags on a container.

273

274

Parameters:

275

- resource_group_name: Name of the resource group

276

- account_name: Name of the storage account

277

- container_name: Name of the blob container

278

- legal_hold: Legal hold configuration

279

280

Returns:

281

Applied LegalHold configuration

282

"""

283

284

def clear_legal_hold(

285

self,

286

resource_group_name: str,

287

account_name: str,

288

container_name: str,

289

legal_hold: LegalHold

290

) -> LegalHold:

291

"""

292

Clears legal hold tags from a container.

293

294

Parameters:

295

- resource_group_name: Name of the resource group

296

- account_name: Name of the storage account

297

- container_name: Name of the blob container

298

- legal_hold: Legal hold tags to clear

299

300

Returns:

301

Updated LegalHold configuration

302

"""

303

```

304

305

### Container Leasing

306

307

Acquire, break, and manage leases on containers for exclusive access control.

308

309

```python { .api }

310

def lease(

311

self,

312

resource_group_name: str,

313

account_name: str,

314

container_name: str,

315

parameters: LeaseContainerRequest

316

) -> LeaseContainerResponse:

317

"""

318

Leases a container for delete operations.

319

320

Parameters:

321

- resource_group_name: Name of the resource group

322

- account_name: Name of the storage account

323

- container_name: Name of the blob container

324

- parameters: Lease operation parameters

325

326

Returns:

327

LeaseContainerResponse with lease information

328

"""

329

```

330

331

Usage example:

332

333

```python

334

from azure.mgmt.storage.models import (

335

LeaseContainerRequest, LeaseContainerRequestEnum, LegalHold

336

)

337

338

# Acquire a lease on container

339

lease_request = LeaseContainerRequest(

340

action=LeaseContainerRequestEnum.ACQUIRE,

341

lease_duration=30 # seconds, -1 for infinite

342

)

343

344

lease_response = client.blob_containers.lease(

345

resource_group_name="my-resource-group",

346

account_name="mystorageaccount123",

347

container_name="private-documents",

348

parameters=lease_request

349

)

350

351

print(f"Lease ID: {lease_response.lease_id}")

352

353

# Set legal hold on container

354

legal_hold = LegalHold(

355

tags=["LegalCase2024", "Compliance"],

356

allow_protected_append_writes_all=False

357

)

358

359

client.blob_containers.set_legal_hold(

360

resource_group_name="my-resource-group",

361

account_name="mystorageaccount123",

362

container_name="legal-documents",

363

legal_hold=legal_hold

364

)

365

```

366

367

### Blob Inventory Policies

368

369

Configure and manage blob inventory policies for automated reporting on blob data.

370

371

```python { .api }

372

class BlobInventoryPoliciesOperations:

373

def create_or_update(

374

self,

375

resource_group_name: str,

376

account_name: str,

377

blob_inventory_policy_name: BlobInventoryPolicyName,

378

properties: BlobInventoryPolicy

379

) -> BlobInventoryPolicy:

380

"""

381

Sets the blob inventory policy for the specified storage account.

382

383

Parameters:

384

- resource_group_name: Name of the resource group

385

- account_name: Name of the storage account

386

- blob_inventory_policy_name: Name of the blob inventory policy

387

- properties: Blob inventory policy properties

388

389

Returns:

390

Created or updated BlobInventoryPolicy

391

"""

392

393

def get(

394

self,

395

resource_group_name: str,

396

account_name: str,

397

blob_inventory_policy_name: BlobInventoryPolicyName

398

) -> BlobInventoryPolicy:

399

"""

400

Gets the blob inventory policy associated with the specified storage account.

401

402

Parameters:

403

- resource_group_name: Name of the resource group

404

- account_name: Name of the storage account

405

- blob_inventory_policy_name: Name of the blob inventory policy

406

407

Returns:

408

BlobInventoryPolicy configuration

409

"""

410

411

def delete(

412

self,

413

resource_group_name: str,

414

account_name: str,

415

blob_inventory_policy_name: BlobInventoryPolicyName

416

) -> None:

417

"""

418

Deletes the blob inventory policy associated with the specified storage account.

419

420

Parameters:

421

- resource_group_name: Name of the resource group

422

- account_name: Name of the storage account

423

- blob_inventory_policy_name: Name of the blob inventory policy

424

"""

425

426

def list(

427

self,

428

resource_group_name: str,

429

account_name: str

430

) -> ItemPaged[ListBlobInventoryPolicy]:

431

"""

432

Gets the blob inventory policies for the specified storage account.

433

434

Parameters:

435

- resource_group_name: Name of the resource group

436

- account_name: Name of the storage account

437

438

Returns:

439

Paginated list of blob inventory policies

440

"""

441

```

442

443

Usage example:

444

445

```python

446

from azure.mgmt.storage.models import (

447

BlobInventoryPolicy, BlobInventoryPolicyDefinition,

448

BlobInventoryPolicyRule, BlobInventoryPolicyFilter,

449

BlobInventoryPolicyName, InventoryRuleType, Format

450

)

451

452

# Create blob inventory policy

453

inventory_rule = BlobInventoryPolicyRule(

454

enabled=True,

455

name="DailyInventory",

456

destination="inventory-reports",

457

definition=BlobInventoryPolicyDefinition(

458

format=Format.CSV,

459

schedule="Daily",

460

object_type=InventoryRuleType.BLOB,

461

schema_fields=[

462

"Name", "Content-Length", "LastModified",

463

"Content-Type", "AccessTier", "BlobType"

464

],

465

filters=BlobInventoryPolicyFilter(

466

prefix_match=["data/", "logs/"],

467

blob_types=["blockBlob", "appendBlob"]

468

)

469

)

470

)

471

472

inventory_policy = BlobInventoryPolicy(

473

properties=BlobInventoryPolicyProperties(

474

policy=BlobInventoryPolicySchema(

475

enabled=True,

476

type_="Inventory",

477

rules=[inventory_rule]

478

)

479

)

480

)

481

482

created_policy = client.blob_inventory_policies.create_or_update(

483

resource_group_name="my-resource-group",

484

account_name="mystorageaccount123",

485

blob_inventory_policy_name=BlobInventoryPolicyName.DEFAULT,

486

properties=inventory_policy

487

)

488

```

489

490

## Types

491

492

```python { .api }

493

class BlobServiceProperties:

494

"""Blob service properties configuration."""

495

id: str

496

name: str

497

type_: str

498

properties: BlobServicePropertiesProperties

499

500

class BlobContainer:

501

"""Blob container resource."""

502

id: str

503

name: str

504

type_: str

505

etag: str

506

properties: BlobContainerProperties

507

508

class BlobContainerProperties:

509

"""Properties of a blob container."""

510

public_access: PublicAccess

511

last_modified_time: datetime

512

lease_status: LeaseStatus

513

lease_state: LeaseState

514

lease_duration: LeaseDuration

515

metadata: Dict[str, str]

516

immutability_policy: ImmutabilityPolicyProperties

517

legal_hold: LegalHoldProperties

518

has_legal_hold: bool

519

has_immutability_policy: bool

520

521

class ListContainerItem:

522

"""Container item in list results."""

523

name: str

524

deleted: bool

525

version: str

526

properties: BlobContainerProperties

527

528

class DeleteRetentionPolicy:

529

"""Delete retention policy configuration."""

530

enabled: bool

531

days: int

532

allow_permanent_delete: bool

533

534

class BlobInventoryPolicy:

535

"""Blob inventory policy resource."""

536

id: str

537

name: str

538

type_: str

539

system_data: SystemData

540

properties: BlobInventoryPolicyProperties

541

542

class PublicAccess(str, Enum):

543

"""Container public access levels."""

544

NONE = "None"

545

BLOB = "Blob"

546

CONTAINER = "Container"

547

548

class LeaseStatus(str, Enum):

549

"""Container lease status."""

550

LOCKED = "Locked"

551

UNLOCKED = "Unlocked"

552

553

class LeaseState(str, Enum):

554

"""Container lease state."""

555

AVAILABLE = "Available"

556

LEASED = "Leased"

557

EXPIRED = "Expired"

558

BREAKING = "Breaking"

559

BROKEN = "Broken"

560

```