Use storage mounts in Azure container applications (2023)

  • Article
  • 8 minutes to read

A container application has access to different types of storage. A single app can use more than one type of storage if necessary.

storage typeDescriptionApplication Examples
container file systemTemporary storage at local container scopeWrite a local application cache.
ephemeral storageTemporary storage limited to a single replicaFile sharing between containers in a replica. For example, the parent application container can write log files that are processed by a child container.
blue filespermanent storageWrite files to a file share to make the data accessible from other systems.

container file system

A container can write to its own file system.

Container file system storage has the following properties:

  • The storage is temporary and disappears when the container is shut down or restarted.
  • Files written to this memory are only visible to processes running in the current container.
  • There are no capacity guarantees. The available storage depends on the amount of storage space available in the container.

ephemeral volume

You can mount a temporary, ephemeral volume that matchesVazioDirin Kubernetes. Volatile storage is limited to a single replica.

Volatile memory has the following characteristics:

(Video) Azure Container Apps - Volumes and Storage Mounts + Azure File Shares

  • Files are retained for the life of the replica.

    • When a container is restarted on a replica, the files on the volume remain intact.
  • Any container in the replica can mount the same volume.

  • A container can mount multiple ephemeral volumes.

  • Available memory depends on the total number of vCPUs allocated to the replica.

    vCPUephemeral storage
    bis 0,251GB
    bis 0,52GB
    bis 14 GB
    above 18 GB

To configure ephemeral storage, first define aVazioDirvolume in the review. Then define a volume mount for one or more containers in the patch.

requirements

Applicationinstructions
Azure-Kontoif you don't have anyCreate a free account.
Azure container application environmentCreate an environment for container applications.

Ideas

When configuring ephemeral storage with the Azure CLI, you must use a YAML definition to create or update your containerized application.

  1. To update an existing container app to use ephemeral storage, export your app's specification to a YAML file namedapplication.yaml.

    az containerapp show -n <APPLICATION_NAME> -g <RESOURCE_GROUP_NAME> -o yaml > app.yaml
  2. Make the following changes to the container application specification.

    • add avolumesMatrix for theModelfrom your container application definition and define a volume. if you already have onevolumesArray, add a new volume to the array.
      • oNameis an identifier for the volume.
      • To useVazioDirWhilestorage type.
    • For each container in the model that you want to mount the ephemeral volume to, define a volume mount on thevolume mountsContainer definition matrix.
      • ovolume nameis the name defined involumesDiversity.
      • oMonte pathis the path in the container to mount the volume.
    Eigenschaften: ManagedEnvironmentId: /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.App/ ManagedEnvironments/<ENVIRONMENT_NAME> configuration: activeRevisionsMode: Single model: container: - image: <NOMBRE_IMAGEN> name: my-container volumeMounts: - MountPath: /myempty VolumeName: myempty Volumes: - name: myempty storageType: EmptyDir
  3. Update your container app using the YAML file.

    az containerapp update --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> \ --yaml app.yaml

Watch theYAML specificationfor a complete example.

To create an ephemeral volume and mount it in a container, make the following changes to the container's apply function in an ARM template:

  • add avolumesMatrix for theModelfrom your container application definition and define a volume. if you already have onevolumesArray, add a new volume to the array.
    • oNameis an identifier for the volume.
    • To useVazioDirWhilestorage type.
  • For each container in the model for which you want to provide temporary storage, define a volume mount on thevolume mountsContainer definition matrix.
    • ovolume nameis the name defined involumesDiversity.
    • oMonte pathis the path in the container to mount the volume.

Example ARM model snippet:

{ "apiVersion": "2022-03-01", "type": "Microsoft.App/containerApps", "name": "[params('containerappName')]", "location": "[params('location ')]", "properties": { ... "template": { "revisionSuffix": "myrevision", "containers": [ { "name": "main", "image": "[parameters('container_image ')]", "resources": { "cpu": 0.5, "memory": "1Gi" }, "volumeMounts": [ { "mountPath": "/myempty", "volumeName": "myempty" } ] } ], "scale": { "minReplicas": 1, "maxReplicas": 3 }, "volumes": [ { "name": "myempty", "storageType": "EmptyDir" } ] } }}

Watch theARM Model API Specificationfor a complete example.

To create an ephemeral volume and mount it in a container, deploy a new patch to your container application through the Azure portal.

  1. Navigate to your container app in the Azure portal.

  2. chooserevision managementno menu on the left.

  3. choosecreate a new review.

  4. Select the container in which you want to mount the volume.

  5. NOedit a containercontext panel, select thevolume mountsab.

  6. Lowephemeral storagesection, create a new volume with the following information.

    • volume name: A name for the volatile volume.
    • mount path: The absolute path in the container to mount the volume.
  7. choosesave to computerto save the changes and exit the context window.

  8. chooseCreateto create the new revision.

(Video) How to mount Azure Storage as a local share in a container app in App Service | Azure Portal Series

Azure-Dateivolumen

You can mount a file share fromblue filesas a volume in a container.

Azure File Storage has the following characteristics:

  • Files written to the mount location are kept on the file share.
  • The files on the share are available through the mount location.
  • Multiple containers can mount the same file share, including those in a different container application, patch, or replica.
  • All containers that mount the share can access files written by other containers or methods.
  • More than one Azure Files volume can be mounted to a single container.

To enable Azure File Storage in your container, you need to configure your container as follows:

  • Create a storage definition in the container app environment.
  • Define a volume of typeAzureDateinambrein a review.
  • Define a volume mount for one or more containers in the patch.

requirements

Applicationinstructions
Azure-Kontoif you don't have anyCreate a free account.
Azure storage accountCreate a storage account.
Azure container application environmentCreate an environment for container applications.

Ideas

When configuring a container application to mount an Azure Files volume using the Azure CLI, you must use a YAML definition to create or update your container application.

For step-by-step instructions, seeCreate an Azure File Storage deployment in Azure Container Apps.

  1. Add a storage definition to your container application environment.

    (Video) Using Azure File Shares as Container Volume Mounts in App Services

    az containerapp env conjunto de almacenamiento --name my-env --resource-group my-group \ --storage-name mystorage \ --azure-file-account-name <STORAGE_ACCOUNT_NAME> \ --azure-file-account-key < STORAGE_ACCOUNT_KEY> \ --azure-file-share-name <STORAGE_SHARE_NAME> \ --access-mode ReadWrite

    Substitute<STORAGE_ACCOUNT_NAME>mi<KEY_ACCOUNT_STORAGE>with the name and password of your storage account. Substitute<SHARED_STORAGE_NAME>with the name of the file share in the storage account.

    Values ​​valid for--Access modethey areRead writemiI just read.

  2. To update an existing container app to mount a file share, export your app's specification to a YAML file namedapplication.yaml.

    az containerapp show -n <APPLICATION_NAME> -g <RESOURCE_GROUP_NAME> -o yaml > app.yaml
  3. Make the following changes to the container application specification.

    • add avolumesMatrix for theModelfrom your container application definition and define a volume. if you already have onevolumesArray, add a new volume to the array.
      • oNameis an identifier for the volume.
      • Forstorage type, to useAzureDateinambre.
      • Forsave nameuse the storage name defined in the environment.
    • Define a volume mount for each container in the template where you want to mount Azure File Storagevolume mountsContainer definition matrix.
      • ovolume nameis the name defined involumesDiversity.
      • oMonte pathis the path in the container to mount the volume.
    Eigenschaften: ManagedEnvironmentId: /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.App/ ManagedEnvironments/<ENVIRONMENT_NAME> configuração: template: containers: - image: <IMAGE_NAME> name: my-container volumeMounts: - volumeName: azure-files-volume mountPath: /my-files volumes: – nombre: azure-files-volume storageType: AzureFile storageName: mystorage
  4. Update your container app using the YAML file.

    az containerapp update --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> \ --yaml app.yaml

Watch theYAML specificationfor a complete example.

The following ARM template snippets demonstrate how to add an Azure Files share to a containerized application environment and use it in a containerized application.

  1. add aStorageSecondary resource for the container application environment.

    { "tipo": "Microsoft.App/ ManagedEnvironments", "apiVersion": "2022-03-01", "name": "[parameters('environment_name')]", "ubicación": "[parameters('ubicación ')]", "properties": { "daprAIInstrumentationKey": "[parameters('dapr_ai_instrumentation_key')]", "appLogsConfiguration": { "destination": "log-analytics", "logAnalyticsConfiguration": { "customerId": " [parameters('log_analytics_customer_id')]", "sharedKey": "[parameters('log_analytics_shared_key')]" } } }, "resources": [ { "type": "almacenmiento", "name": "myazurefiles", "apiVersion": "2022-03-01", "depends on": [ "[resourceId('Microsoft.App/managedEnvironments', params('environment_name'))]" ], "properties": { "azureFile": { "accountName": "[parameters('storage_account_name')]", "accountKey": "[parameters('storage_account_key')]", "shareName": "[parameters('storage_share_name')]", "accessMode": " Read write" } } } ]}
  2. Update the container application resource to add a volume and volume mount.

    { "apiVersion": "2022-03-01", "type": "Microsoft.App/containerApps", "name": "[params('containerappName')]", "location": "[params('location ')]", "properties": { ... "template": { "revisionSuffix": "myrevision", "containers": [ { "name": "main", "image": "[parameters('container_image ')]", "resources": { "cpu": 0.5, "memory": "1Gi" }, "volumeMounts": [ { "mountPath": "/myfiles", "volumeName": "azure-files-volume " } ] } ], "scale": { "minReplicas": 1, "maxReplicas": 3 }, "volumes": [ { "name": "azure-files-volume", "storageType": "AzureFile", "storageName": "myazurefiles" } ] } }}
    • add avolumesMatrix for theModelfrom your container application definition and define a volume. if you already have onevolumesArray, add a new volume to the array.
      • oNameis an identifier for the volume.
      • Forstorage type, to useAzureDateinambre.
      • Forsave nameuse the storage name defined in the environment.
    • Define a volume mount for each container in the template where you want to mount Azure File Storagevolume mountsContainer definition matrix.
      • ovolume nameis the name defined involumesDiversity.
      • oMonte pathis the path in the container to mount the volume.

Watch theARM Model API Specificationfor a complete example.

To configure a volume mount for Azure File Storage in the Azure portal, add a file share to your container application's environment, and then add a volume mount to your container application by creating a new revision.

  1. Navigate to your container app environment in the Azure portal.

  2. chooseblue filesno menu on the left.

  3. chooseadd.

    (Video) Azure Container Apps on File Storage

  4. NOadd file sharecontext menu enter the following information:

    • Name: A name for the file share.
    • Storage account name: The name of the storage account that contains the file share.
    • storage account key: The access key for the storage account.
    • data exchange: The name of the file share.
    • access mode: The access mode for file sharing. Valid values ​​are Read/Write and Read Only.
  5. chooseaddto exit the context box.

  6. choosesave to computerto confirm the changes.

  7. Navigate to your container app.

  8. chooserevision managementno menu on the left.

  9. choosecreate a new review.

  10. Select the container in which you want to mount the volume.

  11. NOedit a containercontext panel, select thevolume mountsab.

  12. Lowfile sharessection, create a new volume with the following information.

    • File share name: The shared file you added.
    • mount path: The absolute path in the container to mount the volume.
  13. choosesave to computerto save the changes and exit the context window.

  14. chooseCreateto create the new revision.

Opinion

Send and view feedback

Show all page comments

(Video) Azure Container Instances Tutorial | Serverless containers in cloud

Videos

1. HOW TO USE DATA VOLUMES IN AZURE CONTAINER INSTANCES
(asar cloud Chef)
2. Mount Azure Blob Storage Container to Local Windows System
(NetSec)
3. [Blobfuse] Mount Azure blob container on Linux | Blob storage as a file system with blobfuse
(LinuxFork)
4. Microsoft Azure Storage Containers and Shared Drive Setup
(cobuman)
5. Azure FILE Share Explained with DEMO Step by step Tutorial
(Paddy Maddy)
6. Tip 12: Deploying a container image to Azure App Service from Docker Hub
(Microsoft DevRadio)
Top Articles
Latest Posts
Article information

Author: Lakeisha Bayer VM

Last Updated: 06/29/2023

Views: 5477

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lakeisha Bayer VM

Birthday: 1997-10-17

Address: Suite 835 34136 Adrian Mountains, Floydton, UT 81036

Phone: +3571527672278

Job: Manufacturing Agent

Hobby: Skimboarding, Photography, Roller skating, Knife making, Paintball, Embroidery, Gunsmithing

Introduction: My name is Lakeisha Bayer VM, I am a brainy, kind, enchanting, healthy, lovely, clean, witty person who loves writing and wants to share my knowledge and understanding with you.