- 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 type | Description | Application Examples |
---|---|---|
container file system | Temporary storage at local container scope | Write a local application cache. |
ephemeral storage | Temporary storage limited to a single replica | File sharing between containers in a replica. For example, the parent application container can write log files that are processed by a child container. |
blue files | permanent storage | Write 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:
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.
vCPU ephemeral storage bis 0,25 1GB bis 0,5 2GB bis 1 4 GB above 1 8 GB
To configure ephemeral storage, first define aVazioDir
volume in the review. Then define a volume mount for one or more containers in the patch.
requirements
Application | instructions |
---|---|
Azure-Konto | if you don't have anyCreate a free account. |
Azure container application environment | Create 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.
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
Make the following changes to the container application specification.
- add a
volumes
Matrix for theModel
from your container application definition and define a volume. if you already have onevolumes
Array, add a new volume to the array.- o
Name
is an identifier for the volume. - To use
VazioDir
Whilestorage type
.
- o
- For each container in the model that you want to mount the ephemeral volume to, define a volume mount on the
volume mounts
Container definition matrix.- o
volume name
is the name defined involumes
Diversity. - o
Monte path
is the path in the container to mount the volume.
- o
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
- add a
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 a
volumes
Matrix for theModel
from your container application definition and define a volume. if you already have onevolumes
Array, add a new volume to the array.- o
Name
is an identifier for the volume. - To use
VazioDir
Whilestorage type
.
- o
- For each container in the model for which you want to provide temporary storage, define a volume mount on the
volume mounts
Container definition matrix.- o
volume name
is the name defined involumes
Diversity. - o
Monte path
is the path in the container to mount the volume.
- o
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.
Navigate to your container app in the Azure portal.
chooserevision managementno menu on the left.
choosecreate a new review.
Select the container in which you want to mount the volume.
NOedit a containercontext panel, select thevolume mountsab.
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.
choosesave to computerto save the changes and exit the context window.
chooseCreateto create the new revision.
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 type
AzureDateinambre
in a review. - Define a volume mount for one or more containers in the patch.
requirements
Application | instructions |
---|---|
Azure-Konto | if you don't have anyCreate a free account. |
Azure storage account | Create a storage account. |
Azure container application environment | Create 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.
Add a storage definition to your container application environment.
(Video) Using Azure File Shares as Container Volume Mounts in App Servicesaz 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 mode
they areRead write
miI just read
.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
Make the following changes to the container application specification.
- add a
volumes
Matrix for theModel
from your container application definition and define a volume. if you already have onevolumes
Array, add a new volume to the array.- o
Name
is an identifier for the volume. - For
storage type
, to useAzureDateinambre
. - For
save name
use the storage name defined in the environment.
- o
- Define a volume mount for each container in the template where you want to mount Azure File Storage
volume mounts
Container definition matrix.- o
volume name
is the name defined involumes
Diversity. - o
Monte path
is the path in the container to mount the volume.
- o
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
- add a
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.
add a
Storage
Secondary 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" } } } ]}
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 a
volumes
Matrix for theModel
from your container application definition and define a volume. if you already have onevolumes
Array, add a new volume to the array.- o
Name
is an identifier for the volume. - For
storage type
, to useAzureDateinambre
. - For
save name
use the storage name defined in the environment.
- o
- Define a volume mount for each container in the template where you want to mount Azure File Storage
volume mounts
Container definition matrix.- o
volume name
is the name defined involumes
Diversity. - o
Monte path
is the path in the container to mount the volume.
- o
- add a
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.
Navigate to your container app environment in the Azure portal.
chooseblue filesno menu on the left.
chooseadd.
(Video) Azure Container Apps on File StorageNOadd 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.
chooseaddto exit the context box.
choosesave to computerto confirm the changes.
Navigate to your container app.
chooserevision managementno menu on the left.
choosecreate a new review.
Select the container in which you want to mount the volume.
NOedit a containercontext panel, select thevolume mountsab.
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.
choosesave to computerto save the changes and exit the context window.
chooseCreateto create the new revision.
Opinion
Send and view feedback