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/container-apps/storage-mounts-azure-files.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,9 @@ In this tutorial, you learn how to:
24
24
> * Mount the storage share in an individual container
25
25
> * Verify the storage mount by viewing the website access log
26
26
27
+
> [!NOTE]
28
+
> Azure Container Apps supports mounting file shares using SMB and NFS protocols. This tutorial demonstrates mounting an Azure Files share using the SMB protocol. To learn more about mounting NFS shares, see [Use storage mounts in Azure Container Apps](storage-mounts.md).
29
+
27
30
## Prerequisites
28
31
29
32
- Install the latest version of the [Azure CLI](/cli/azure/install-azure-cli).
Copy file name to clipboardExpand all lines: articles/container-apps/storage-mounts.md
+179-9Lines changed: 179 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: craigshoemaker
6
6
ms.service: container-apps
7
7
ms.custom: devx-track-azurecli
8
8
ms.topic: conceptual
9
-
ms.date: 09/13/2023
9
+
ms.date: 04/10/2024
10
10
ms.author: cshoe
11
11
zone_pivot_groups: arm-azure-cli-portal
12
12
---
@@ -23,7 +23,7 @@ A container app has access to different types of storage. A single app can take
23
23
24
24
## Ephemeral storage
25
25
26
-
A container app can read and write temporary data to ephemeral storage. Ephermal storage can be scoped to a container or a replica. The total amount of container-scoped and replica-scoped storage available to each replica depends on the total amount of vCPUs allocated to the replica.
26
+
A container app can read and write temporary data to ephemeral storage. Ephemeral storage can be scoped to a container or a replica. The total amount of container-scoped and replica-scoped storage available to each replica depends on the total amount of vCPUs allocated to the replica.
27
27
28
28
| vCPUs | Total ephemeral storage |
29
29
|--|--|
@@ -227,12 +227,21 @@ Azure Files storage has the following characteristics:
227
227
* All containers that mount the share can access files written by any other container or method.
228
228
* More than one Azure Files volume can be mounted in a single container.
229
229
230
-
To enable Azure Files storage in your container, you need to set up your container as follows:
230
+
Azure Files supports both SMB and NFS protocols. You can mount an Azure Files share using either protocol. The file share you define in the environment must be configured with the same protocol used by the file share in the storage account.
231
+
232
+
> [!NOTE]
233
+
> Support for mounting NFS shares in Azure Container Apps is in preview.
234
+
235
+
To enable Azure Files storage in your container, you need to set up your environment and container app as follows:
231
236
232
237
* Create a storage definition in the Container Apps environment.
233
-
* Define a volume of type `AzureFile` in a revision.
238
+
* If you are using NFS, your environment must be configured with a custom VNet and the storage account must be configured to allow access from the VNet. For more information, see [NFS file shares in Azure Files
239
+
](../storage/files/files-nfs-protocol.md).
240
+
* If your environment is configured with a custom VNet, you must allow ports 445 and 2049 in the network security group (NSG) associated with the subnet.
241
+
* Define a volume of type `AzureFile` (SMB) or `NfsAzureFile` (NFS) in a revision.
234
242
* Define a volume mount in one or more containers in the revision.
235
243
* The Azure Files storage account used must be accessible from your container app's virtual network. For more information, see [Grant access from a virtual network](/azure/storage/common/storage-network-security#grant-access-from-a-virtual-network).
244
+
* If you're using NFS, you must also disable secure transfer. For more information, see [NFS file shares in Azure Files](../storage/files/files-nfs-protocol.md) and the *Create an NFS Azure file share* section in [this tutorial](../storage/files/storage-files-quick-create-use-linux.md#create-an-nfs-azure-file-share).
236
245
237
246
### Prerequisites
238
247
@@ -248,13 +257,16 @@ To enable Azure Files storage in your container, you need to set up your contain
248
257
249
258
When configuring a container app to mount an Azure Files volume using the Azure CLI, you must use a YAML definition to create or update your container app.
250
259
251
-
For a step-by-step tutorial, refer to [Create an Azure Files storage mount in Azure Container Apps](storage-mounts-azure-files.md).
260
+
For a step-by-step tutorial on mounting an SMB file share, refer to [Create an Azure Files storage mount in Azure Container Apps](storage-mounts-azure-files.md).
252
261
253
262
1. Add a storage definition to your Container Apps environment.
254
-
263
+
264
+
# [SMB](#tab/smb)
265
+
255
266
```azure-cli
256
267
az containerapp env storage set --name my-env --resource-group my-group \
@@ -265,6 +277,28 @@ For a step-by-step tutorial, refer to [Create an Azure Files storage mount in Az
265
277
266
278
Valid values for `--access-mode` are `ReadWrite` and `ReadOnly`.
267
279
280
+
# [NFS](#tab/nfs)
281
+
282
+
```azure-cli
283
+
az containerapp env storage set --name my-env --resource-group my-group \
284
+
--storage-name mystorage \
285
+
--storage-type NfsAzureFile \
286
+
--server <NFS_SERVER> \
287
+
--azure-file-share-name <STORAGE_SHARE_NAME> \
288
+
--access-mode ReadWrite
289
+
```
290
+
291
+
Replace `<NFS_SERVER>` with the NFS server address in the format `<STORAGE_ACCOUNT_NAME>.file.core.windows.net`. For example, if your storage account name is `mystorageaccount`, the NFS server address is `mystorageaccount.file.core.windows.net`.
292
+
293
+
Replace `<STORAGE_SHARE_NAME>` with the name of the file share in the format `/<STORAGE_ACCOUNT_NAME>/<STORAGE_SHARE_NAME>`. For example, if your storage account name is `mystorageaccount` and the file share name is `myshare`, the share name is `/mystorageaccount/myshare`.
294
+
295
+
Valid values for `--access-mode` are `ReadWrite` and `ReadOnly`.
296
+
297
+
> [!NOTE]
298
+
> To mount NFS Azure Files, you must use a Container Apps environment with a custom VNet. The Storage account must be configured to allow access from the VNet.
299
+
300
+
---
301
+
268
302
1. To update an existing container app to mount a file share, export your app's specification to a YAML file named *app.yaml*.
269
303
270
304
```azure-cli
@@ -275,12 +309,14 @@ For a step-by-step tutorial, refer to [Create an Azure Files storage mount in Az
275
309
276
310
- Add a `volumes` array to the `template` section of your container app definition and define a volume. If you already have a `volumes` array, add a new volume to the array.
277
311
- The `name` is an identifier for the volume.
278
-
- For `storageType`, use `AzureFile`.
312
+
- For `storageType`, use `AzureFile` for SMB, or `NfsAzureFile` for NFS. This value must match the storage type you defined in the environment.
279
313
- For `storageName`, use the name of the storage you defined in the environment.
280
314
- For each container in the template that you want to mount Azure Files storage, define a volume mount in the `volumeMounts` array of the container definition.
281
315
- The `volumeName` is the name defined in the `volumes` array.
282
316
- The `mountPath` is the path in the container to mount the volume.
> To mount NFS Azure Files, you must use a Container Apps environment with a custom VNet. The Storage account must be configured to allow access from the VNet.
464
+
465
+
---
466
+
355
467
1. Update the container app resource to add a volume and volume mount.
356
468
469
+
# [SMB](#tab/smb)
470
+
357
471
```json
358
472
{
359
-
"apiVersion": "2022-03-01",
473
+
"apiVersion": "2023-05-01",
360
474
"type": "Microsoft.App/containerApps",
361
475
"name": "[parameters('containerappName')]",
362
476
"location": "[parameters('location')]",
@@ -398,9 +512,57 @@ The following ARM template snippets demonstrate how to add an Azure Files share
398
512
}
399
513
```
400
514
515
+
# [NFS](#tab/nfs)
516
+
517
+
```json
518
+
{
519
+
"apiVersion": "2023-11-02-preview",
520
+
"type": "Microsoft.App/containerApps",
521
+
"name": "[parameters('containerappName')]",
522
+
"location": "[parameters('location')]",
523
+
"properties": {
524
+
525
+
...
526
+
527
+
"template": {
528
+
"revisionSuffix": "myrevision",
529
+
"containers": [
530
+
{
531
+
"name": "main",
532
+
"image": "[parameters('container_image')]",
533
+
"resources": {
534
+
"cpu": 0.5,
535
+
"memory": "1Gi"
536
+
},
537
+
"volumeMounts": [
538
+
{
539
+
"mountPath": "/myfiles",
540
+
"volumeName": "azure-files-volume"
541
+
}
542
+
]
543
+
}
544
+
],
545
+
"scale": {
546
+
"minReplicas": 1,
547
+
"maxReplicas": 3
548
+
},
549
+
"volumes": [
550
+
{
551
+
"name": "azure-files-volume",
552
+
"storageType": "NfsAzureFile",
553
+
"storageName": "myazurefiles"
554
+
}
555
+
]
556
+
}
557
+
}
558
+
}
559
+
```
560
+
561
+
---
562
+
401
563
- Add a `volumes` array to the `template` section of your container app definition and define a volume. If you already have a `volumes` array, add a new volume to the array.
402
564
- The `name` is an identifier for the volume.
403
-
- For `storageType`, use `AzureFile`.
565
+
- For `storageType`, use `AzureFile` for SMB, or `NfsAzureFile` for NFS. This value must match the storage type you defined in the environment.
404
566
- For `storageName`, use the name of the storage you defined in the environment.
405
567
- For each container in the template that you want to mount Azure Files storage, define a volume mount in the `volumeMounts` array of the container definition.
406
568
- The `volumeName` is the name defined in the `volumes` array.
@@ -412,6 +574,8 @@ See the [ARM template API specification](azure-resource-manager-api-spec.md) for
412
574
413
575
::: zone pivot="azure-portal"
414
576
577
+
# [SMB](#tab/smb)
578
+
415
579
To configure a volume mount for Azure Files storage in the Azure portal, add a file share to your Container Apps environment and then add a volume mount to your container app by creating a new revision.
416
580
417
581
1. In the Azure portal, navigate to your Container Apps environment.
@@ -451,4 +615,10 @@ To configure a volume mount for Azure Files storage in the Azure portal, add a f
451
615
452
616
1. Select **Create** to create the new revision.
453
617
618
+
# [NFS](#tab/nfs)
619
+
620
+
Azure portal doesn't support creating NFS Azure Files volumes. To create an NFS Azure Files volume, use the [Azure CLI](storage-mounts.md?tabs=nfs&pivots=azure-cli#azure-files) or [ARM template](storage-mounts.md?tabs=nfs&pivots=azure-resource-manager#azure-files).
0 commit comments