or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

connection-configuration.mdfile-management.mdindex.mdmigration-task-types.mdproject-management.mdresource-information.mdservice-management.mdservice-tasks.mdtask-execution.md

file-management.mddocs/

0

# File Management

1

2

Operations for managing project files including migration scripts, configuration files, and other migration assets. Files provide a way to store and retrieve migration-related documents, scripts, and configuration data within projects.

3

4

## Capabilities

5

6

### Create or Update File

7

8

Creates a new project file or updates an existing one.

9

10

```python { .api }

11

def create_or_update(

12

group_name: str,

13

service_name: str,

14

project_name: str,

15

file_name: str,

16

parameters: ProjectFile,

17

**kwargs

18

) -> ProjectFile:

19

"""

20

Creates or updates a project file.

21

22

Parameters:

23

- group_name: Name of the resource group

24

- service_name: Name of the Data Migration Service

25

- project_name: Name of the project

26

- file_name: Name of the file

27

- parameters: File properties and metadata

28

29

Returns:

30

ProjectFile object with file metadata

31

"""

32

```

33

34

### Get File

35

36

Retrieves metadata for a project file.

37

38

```python { .api }

39

def get(

40

group_name: str,

41

service_name: str,

42

project_name: str,

43

file_name: str,

44

**kwargs

45

) -> ProjectFile:

46

"""

47

Gets project file metadata.

48

49

Parameters:

50

- group_name: Name of the resource group

51

- service_name: Name of the Data Migration Service

52

- project_name: Name of the project

53

- file_name: Name of the file

54

55

Returns:

56

ProjectFile with metadata and properties

57

"""

58

```

59

60

### Delete File

61

62

Deletes a project file.

63

64

```python { .api }

65

def delete(

66

group_name: str,

67

service_name: str,

68

project_name: str,

69

file_name: str,

70

**kwargs

71

) -> None:

72

"""

73

Deletes a project file.

74

75

Parameters:

76

- group_name: Name of the resource group

77

- service_name: Name of the Data Migration Service

78

- project_name: Name of the project

79

- file_name: Name of the file

80

81

Returns:

82

None

83

"""

84

```

85

86

### Update File

87

88

Updates properties of an existing project file.

89

90

```python { .api }

91

def update(

92

group_name: str,

93

service_name: str,

94

project_name: str,

95

file_name: str,

96

parameters: ProjectFile,

97

**kwargs

98

) -> ProjectFile:

99

"""

100

Updates a project file.

101

102

Parameters:

103

- group_name: Name of the resource group

104

- service_name: Name of the Data Migration Service

105

- project_name: Name of the project

106

- file_name: Name of the file

107

- parameters: Updated file properties

108

109

Returns:

110

Updated ProjectFile object

111

"""

112

```

113

114

### List Files

115

116

Lists all files within a project.

117

118

```python { .api }

119

def list(

120

group_name: str,

121

service_name: str,

122

project_name: str,

123

**kwargs

124

) -> ItemPaged[ProjectFile]:

125

"""

126

Lists project files.

127

128

Parameters:

129

- group_name: Name of the resource group

130

- service_name: Name of the Data Migration Service

131

- project_name: Name of the project

132

133

Returns:

134

Paged collection of ProjectFile objects

135

"""

136

```

137

138

### Read File

139

140

Gets download URL for reading file content.

141

142

```python { .api }

143

def read(

144

group_name: str,

145

service_name: str,

146

project_name: str,

147

file_name: str,

148

**kwargs

149

) -> FileStorageInfo:

150

"""

151

Gets file download information.

152

153

Parameters:

154

- group_name: Name of the resource group

155

- service_name: Name of the Data Migration Service

156

- project_name: Name of the project

157

- file_name: Name of the file

158

159

Returns:

160

FileStorageInfo with download URL and headers

161

"""

162

```

163

164

**Usage Example:**

165

166

```python

167

import requests

168

169

# Get download access for a migration script

170

file_info = client.files.read(

171

group_name="myResourceGroup",

172

service_name="myMigrationService",

173

project_name="myProject",

174

file_name="migration-script.sql"

175

)

176

177

# Download the file content using the provided URI and headers

178

response = requests.get(file_info.uri, headers=file_info.headers)

179

if response.status_code == 200:

180

file_content = response.text

181

print(f"Downloaded file content: {len(file_content)} characters")

182

else:

183

print(f"Download failed with status: {response.status_code}")

184

```

185

186

### Read/Write File Access

187

188

Gets both download and upload URLs for file access.

189

190

```python { .api }

191

def read_write(

192

group_name: str,

193

service_name: str,

194

project_name: str,

195

file_name: str,

196

**kwargs

197

) -> FileStorageInfo:

198

"""

199

Gets file read/write access information.

200

201

Parameters:

202

- group_name: Name of the resource group

203

- service_name: Name of the Data Migration Service

204

- project_name: Name of the project

205

- file_name: Name of the file

206

207

Returns:

208

FileStorageInfo with both upload and download URLs

209

"""

210

```

211

212

**Usage Example:**

213

214

```python

215

import requests

216

217

# Get read/write access for a configuration file

218

file_info = client.files.read_write(

219

group_name="myResourceGroup",

220

service_name="myMigrationService",

221

project_name="myProject",

222

file_name="config.json"

223

)

224

225

# Download existing content (if any)

226

response = requests.get(file_info.uri, headers=file_info.headers)

227

if response.status_code == 200:

228

existing_content = response.json()

229

print("Downloaded existing configuration")

230

else:

231

existing_content = {}

232

233

# Modify content

234

existing_content['updated'] = True

235

existing_content['timestamp'] = '2023-01-01T00:00:00Z'

236

237

# Upload updated content using the same URI and headers

238

upload_response = requests.put(

239

file_info.uri,

240

headers=file_info.headers,

241

json=existing_content

242

)

243

244

if upload_response.status_code in [200, 201]:

245

print("Successfully updated file content")

246

else:

247

print(f"Upload failed with status: {upload_response.status_code}")

248

```

249

250

## File Types and Configuration

251

252

### ProjectFile

253

254

```python { .api }

255

class ProjectFile:

256

"""Project file resource definition."""

257

258

def __init__(self, properties: ProjectFileProperties = None, **kwargs):

259

"""

260

Initialize project file.

261

262

Parameters:

263

- properties: File properties and metadata

264

"""

265

266

# Properties

267

etag: str # Entity tag for concurrency control

268

properties: ProjectFileProperties # File properties

269

id: str # Resource ID

270

name: str # Resource name

271

type: str # Resource type

272

```

273

274

### ProjectFileProperties

275

276

```python { .api }

277

class ProjectFileProperties:

278

"""Project file properties and metadata."""

279

280

def __init__(self, **kwargs):

281

"""Initialize file properties."""

282

283

# Properties

284

extension: str # File extension

285

file_path: str # File path within project

286

last_modified: datetime # Last modification timestamp

287

media_type: str # MIME type

288

size: int # File size in bytes

289

```

290

291

### FileStorageInfo

292

293

```python { .api }

294

class FileStorageInfo:

295

"""File storage access information."""

296

297

# Properties

298

uri: str # File access URI

299

headers: Dict[str, str] # Required headers for access

300

```

301

302

## Usage Examples

303

304

### Upload Configuration File

305

306

```python

307

from azure.mgmt.datamigration.models import ProjectFile, ProjectFileProperties

308

309

# Create file metadata

310

file_properties = ProjectFileProperties(

311

extension="json",

312

file_path="/config/migration-config.json",

313

media_type="application/json"

314

)

315

316

project_file = ProjectFile(

317

properties=file_properties

318

)

319

320

# Create the file entry

321

file_entry = client.files.create_or_update(

322

group_name="myResourceGroup",

323

service_name="myMigrationService",

324

project_name="myProject",

325

file_name="migration-config.json",

326

parameters=project_file

327

)

328

329

# Get upload URL

330

storage_info = client.files.read_write(

331

group_name="myResourceGroup",

332

service_name="myMigrationService",

333

project_name="myProject",

334

file_name="migration-config.json"

335

)

336

337

print(f"Upload URL: {storage_info.uri}")

338

print(f"Required headers: {storage_info.headers}")

339

```

340

341

### Download Migration Script

342

343

```python

344

# Get download URL for existing file

345

storage_info = client.files.read(

346

group_name="myResourceGroup",

347

service_name="myMigrationService",

348

project_name="myProject",

349

file_name="migration-script.sql"

350

)

351

352

# Use the URL to download the file

353

import requests

354

355

response = requests.get(

356

storage_info.uri,

357

headers=storage_info.headers

358

)

359

360

if response.status_code == 200:

361

script_content = response.text

362

print("Downloaded migration script successfully")

363

else:

364

print(f"Download failed: {response.status_code}")

365

```

366

367

### List and Manage Project Files

368

369

```python

370

# List all files in project

371

files = client.files.list(

372

group_name="myResourceGroup",

373

service_name="myMigrationService",

374

project_name="myProject"

375

)

376

377

for file in files:

378

print(f"File: {file.name}")

379

print(f" Size: {file.properties.size} bytes")

380

print(f" Type: {file.properties.media_type}")

381

print(f" Modified: {file.properties.last_modified}")

382

383

# Delete old files

384

old_files = [f for f in files if f.name.startswith("old_")]

385

for old_file in old_files:

386

client.files.delete(

387

group_name="myResourceGroup",

388

service_name="myMigrationService",

389

project_name="myProject",

390

file_name=old_file.name

391

)

392

print(f"Deleted: {old_file.name}")

393

```

394

395

## File Storage Configuration

396

397

### FileShare

398

399

```python { .api }

400

class FileShare:

401

"""File share configuration."""

402

403

def __init__(self, path: str, **kwargs):

404

"""

405

Parameters:

406

- path: File share path

407

- user_name: Username for file share access

408

- password: Password for file share access

409

"""

410

411

# Properties

412

path: str # Required: File share path

413

user_name: str # Username for access

414

password: str # Password for access

415

```

416

417

### BlobShare

418

419

```python { .api }

420

class BlobShare:

421

"""Azure Blob storage share configuration."""

422

423

def __init__(self, sas_uri: str, **kwargs):

424

"""

425

Parameters:

426

- sas_uri: Blob container SAS URI

427

"""

428

429

# Properties

430

sas_uri: str # Required: SAS URI for blob container

431

```

432

433

## Common File Types

434

435

Project files typically include:

436

437

- **Migration Scripts**: `.sql`, `.js`, `.py` files containing migration logic

438

- **Configuration Files**: `.json`, `.xml`, `.yaml` files with migration settings

439

- **Schema Definitions**: `.sql`, `.json` files defining database schemas

440

- **Data Mapping Files**: `.json`, `.csv` files defining data transformations

441

- **Validation Scripts**: `.sql`, `.py` files for data validation

442

- **Documentation**: `.md`, `.txt` files with migration documentation

443

444

## Error Handling

445

446

Common file operation errors:

447

448

- **File not found**: Specified file doesn't exist in the project

449

- **Access denied**: Insufficient permissions to access file storage

450

- **Storage quota exceeded**: Project file storage limit reached

451

- **Invalid file format**: File type or content not supported

452

- **Network errors**: Temporary issues accessing file storage

453

454

File operations use Azure Storage behind the scenes, so network connectivity and proper authentication are essential for successful file management operations.