You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/concept-file-access-options.md
+64-63Lines changed: 64 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ The rest of this article focuses on mounts: when they're the right choice, and h
40
40
41
41
## What is a storage mount?
42
42
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:
44
44
45
45
```
46
46
┌─────────────────────────────────────┐
@@ -57,11 +57,11 @@ A storage mount is a network file share mounted as if it were a local directory.
57
57
└─────────────────────────────────────┘
58
58
```
59
59
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.
61
61
62
62
## When not to use mounts
63
63
64
-
Mounts aren't the right choice for every scenario:
64
+
Mounts aren't the right choice for every scenario. Consider these alternatives:
65
65
66
66
| Scenario | Recommended alternative |
67
67
| --- | --- |
@@ -73,20 +73,9 @@ Mounts aren't the right choice for every scenario:
73
73
> [!IMPORTANT]
74
74
> Only Flex Consumption and Dedicated (App Service) plans support storage mounts.
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.
126
115
127
116
## Share mount scenarios
128
117
@@ -140,8 +129,8 @@ These example scenarios also benefit from using mounted storage shares:
140
129
141
130
**The problem:** Without mounts, you have two suboptimal options:
142
131
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.
145
134
146
135
**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.
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
+
```
326
343
327
-
### Understand the two auth models
344
+
##Mount authentication
328
345
329
346
Azure Files storage mounts and the Azure SDK use different authentication mechanisms:
330
347
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:
333
352
334
353
```bicep
335
-
// Mount config in Bicep — requires storage account key
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:
383
385
384
-
```python
385
-
from pathlib import Path
386
-
import time
386
+
```python
387
+
from pathlib import Path
388
+
import time
387
389
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
390
392
391
-
defcleanup_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
+
```
398
399
399
400
## Troubleshoot storage mounts
400
401
401
402
The following table lists common issues with Azure Files storage mounts on functionapps:
402
403
403
404
| Issue | Resolution |
404
405
| --- | --- |
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 functionapp 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. |
407
408
| **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. |
408
409
| **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. |
0 commit comments