Skip to content

Commit 848a81c

Browse files
committed
Refactor Azure Functions documentation for improved clarity and consistency in file access strategies and tutorial steps
1 parent 1dd74df commit 848a81c

2 files changed

Lines changed: 229 additions & 229 deletions

File tree

articles/azure-functions/concept-file-access-options.md

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The rest of this article focuses on mounts: when they're the right choice, and h
4040

4141
## What is a storage mount?
4242

43-
A storage mount is a network file share mounted as if it were a local directory. When you mount an Azure Files share on your function app, the path appears in the function container's file system:
43+
A storage mount is a network file share that you mount as if it were a local directory. When you mount an Azure Files share on your function app, the path appears in the function container's file system:
4444

4545
```
4646
┌─────────────────────────────────────┐
@@ -57,11 +57,11 @@ A storage mount is a network file share mounted as if it were a local directory.
5757
└─────────────────────────────────────┘
5858
```
5959

60-
Your code uses standard file system APIs (for example, `open()`, `os.listdir()` in Python, or equivalent calls in other languages) without knowing it's communicating over the network. This provides POSIX semantics, which means your code looks like local file I/O.
60+
Your code uses standard file system APIs (for example, `open()`, `os.listdir()` in Python, or equivalent calls in other languages) without knowing it's communicating over the network. This setup provides POSIX semantics, which means your code looks like local file I/O.
6161

6262
## When not to use mounts
6363

64-
Mounts aren't the right choice for every scenario:
64+
Mounts aren't the right choice for every scenario. Consider these alternatives:
6565

6666
| Scenario | Recommended alternative |
6767
| --- | --- |
@@ -73,20 +73,9 @@ Mounts aren't the right choice for every scenario:
7373
> [!IMPORTANT]
7474
> Only Flex Consumption and Dedicated (App Service) plans support storage mounts.
7575
76-
## Mount limits
77-
78-
| Limit | Value |
79-
| --- | --- |
80-
| Share size | Up to 100 TiB |
81-
| File size | Up to 4 TiB |
82-
| Throughput | ~60 MB/s (standard), ~100+ MB/s (premium) |
83-
| Concurrency | Many (SMB handles it), but writes serialize |
84-
85-
For more information, see [Azure Files scale targets](../storage/files/storage-files-scale-targets.md).
86-
8776
## Compare storage options
8877

89-
Consider our three main file access options when processing 1,000 images (1 MB each) stored in a reference folder:
78+
Consider the three main file access options when processing 1,000 images (1 MB each) stored in a reference folder:
9079

9180
| Approach | Mechanism | Network calls | Relative cost | Best for |
9281
| ---- | ---- | ---- | ---- | ---- |
@@ -122,7 +111,7 @@ reference_data = container.query_items(
122111

123112
---
124113

125-
For large shared files with repeated access, it's best to use share mounts. Let's investigate more detailed scenarios that
114+
For large shared files with repeated access, use share mounts. Let's investigate more detailed scenarios that use share mounts.
126115

127116
## Share mount scenarios
128117

@@ -140,8 +129,8 @@ These example scenarios also benefit from using mounted storage shares:
140129
141130
**The problem:** Without mounts, you have two suboptimal options:
142131

143-
- **Package the reference files with your function**: This leads to a huge deployment artifact, slow cold starts, and storage redundancy.
144-
- **Download from Blob Storage each time**: This introduces network latency on every function invocation and wastes bandwidth.
132+
- **Package the reference files with your function**: This approach results in a huge deployment artifact, slow cold starts, and storage redundancy.
133+
- **Download from Blob Storage each time**: This approach introduces network latency on every function invocation and wastes bandwidth.
145134

146135
**The mount-based solution:** All instances read from the mounted share directly. After mount initialization, there's no per-request network overhead and no redundant storage.
147136

@@ -247,7 +236,7 @@ def process_video(video_file: str) -> str:
247236

248237
**Performance implications:**
249238

250-
- **First execution**: SMB mount initialization adds approximately 200-500 ms.
239+
- **First execution**: SMB mount initialization adds approximately 200-500 milliseconds.
251240
- **Subsequent executions**: Direct file access with minimal overhead.
252241
- **Binary caching**: The OS caches the binary in memory, reducing repeated disk reads.
253242

@@ -322,17 +311,46 @@ def read_results() -> dict:
322311
323312
---
324313

325-
## Best practices
314+
## Mount limits
315+
316+
These Azure Files storage limits apply to all hosting plans that support mounts:
317+
318+
| Limit | Value |
319+
| --- | --- |
320+
| Share size | Up to 100 TiB |
321+
| File size | Up to 4 TiB |
322+
| Throughput | ~60 MB/s (standard), ~100+ MB/s (premium) |
323+
| Concurrency | Many (SMB handles it), but writes serialize |
324+
325+
For more information, see [Azure Files scale targets](../storage/files/storage-files-scale-targets.md).
326+
327+
These limits vary by supported hosting plan:
328+
329+
| Limit | Flex Consumption | Dedicated (App Service) |
330+
| --- | --- | --- |
331+
| Mount points per app | 5 | 5 |
332+
| Protocols | SMB only | SMB, NFS, Azure Blobs (read-only) |
333+
334+
To prevent runaway storage costs, set a quota on your Azure Files share:
335+
336+
```bash
337+
az storage share-rm update \
338+
--resource-group $RESOURCE_GROUP \
339+
--storage-account $STORAGE_ACCOUNT \
340+
--name myshare \
341+
--quota 100 # 100 GB limit
342+
```
326343

327-
### Understand the two auth models
344+
## Mount authentication
328345

329346
Azure Files storage mounts and the Azure SDK use different authentication mechanisms:
330347

331-
- **Storage mounts (SMB)**: Authenticated with a storage account access key at mount time. The key is stored in the function app's site configuration (`azureStorageAccounts`). Managed identity isn't supported for SMB mounts on Azure Functions.
332-
- **Azure SDK (REST API)**: For programmatic access via the Azure Storage SDK, use managed identity when possible.
348+
- **Storage mounts (SMB)**: Authenticate by using a storage account access key at mount time. The key is stored in the function app's site configuration (`azureStorageAccounts`). Managed identity isn't currently supported for SMB mounts on Azure Functions.
349+
- **Azure SDK (REST API)**: For programmatic access by using the Azure Storage SDK, use managed identity when possible.
350+
351+
This Bicep example configures the storage mount by using the storage account shared secret key:
333352

334353
```bicep
335-
// Mount config in Bicep — requires storage account key
336354
resource mountConfig 'Microsoft.Web/sites/config@2023-12-01' = {
337355
parent: functionApp
338356
name: 'azurestorageaccounts'
@@ -351,59 +369,42 @@ resource mountConfig 'Microsoft.Web/sites/config@2023-12-01' = {
351369
> [!IMPORTANT]
352370
> Rotate storage account keys periodically. When you rotate keys, update the mount configuration on every function app that references the account.
353371
354-
### Set mount quotas
355-
356-
Prevent runaway storage costs by setting a quota on your Azure Files share:
357-
358-
```bash
359-
az storage share-rm update \
360-
--resource-group $RESOURCE_GROUP \
361-
--storage-account $STORAGE_ACCOUNT \
362-
--name myshare \
363-
--quota 100 # 100 GB limit
364-
```
365-
366-
### Monitor file access
367-
368-
Enable diagnostics on your storage account to see mount access patterns:
369-
370-
```bash
371-
az monitor metrics list \
372-
--resource /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/$STORAGE_ACCOUNT/fileServices/default \
373-
--metric Transactions
374-
```
372+
## Best practices
375373

376-
### Use read-only mounts when possible
374+
- **Use read-only mounts when possible.** If your function only reads from the mount, configure it as read-only to prevent accidental writes.
377375

378-
If your function only reads from the mount, configure it as read-only to prevent accidental writes.
376+
- **Monitor file access.** Enable diagnostics on your storage account to track mount access patterns:
379377

380-
### Clean up temporary files
378+
```bash
379+
az monitor metrics list \
380+
--resource /subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Storage/storageAccounts/$STORAGE_ACCOUNT/fileServices/default \
381+
--metric Transactions
382+
```
381383

382-
If your functions write to the mount, implement cleanup:
384+
- **Clean up temporary files.** If your functions write to the mount, implement cleanup to avoid unbounded growth:
383385

384-
```python
385-
from pathlib import Path
386-
import time
386+
```python
387+
from pathlib import Path
388+
import time
387389
388-
MOUNT_PATH = "/mnt/temp"
389-
TEMP_THRESHOLD = 24 * 60 * 60 # 24 hours
390+
MOUNT_PATH = "/mnt/temp"
391+
MAX_AGE = 24 * 60 * 60 # 24 hours
390392
391-
def cleanup_old_files():
392-
"""Remove temp files older than 24 hours."""
393-
cutoff_time = time.time() - TEMP_THRESHOLD
394-
for file_path in Path(MOUNT_PATH).iterdir():
395-
if file_path.stat().st_mtime < cutoff_time:
396-
file_path.unlink()
397-
```
393+
def cleanup_old_files():
394+
cutoff = time.time() - MAX_AGE
395+
for f in Path(MOUNT_PATH).iterdir():
396+
if f.stat().st_mtime < cutoff:
397+
f.unlink()
398+
```
398399

399400
## Troubleshoot storage mounts
400401

401402
The following table lists common issues with Azure Files storage mounts on function apps:
402403

403404
| Issue | Resolution |
404405
| --- | --- |
405-
| **Binary or file not found on mount path** | Verify the file was uploaded to the correct Azure Files share. Check that the mount path configured on the function app matches the path your code references. In the Azure portal, check **Settings** > **Configuration** > **Path Mappings**. |
406-
| **Permission denied when accessing mounted files** | Storage mounts authenticate by using a storage account access key. Verify the key in the mount configuration is correct and hasn't been rotated. When you rotate keys, update the mount configuration on every function app that references the account. |
406+
| **Binary or file not found on mount path** | Verify the file is in the correct Azure Files share. Check that the mount path configured on the function app matches the path your code references. In the Azure portal, check **Settings** > **Configuration** > **Path Mappings**. |
407+
| **Permission denied when accessing mounted files** | Storage mounts authenticate by using a storage account access key. Verify the key in the mount configuration is correct and wasn't rotated. When you rotate keys, update the mount configuration on every function app that references the account. |
407408
| **Binary lacks execute permissions** | Azure Files preserves POSIX permissions set at upload time. Re-upload the binary after running `chmod +x` locally, or set permissions after upload. |
408409
| **Mount adds latency to cold starts** | SMB mount initialization adds approximately 200-500 ms on first execution. Subsequent invocations reuse the mount. For latency-sensitive apps, consider the [always-ready instances](./flex-consumption-plan.md) feature. |
409410

0 commit comments

Comments
 (0)