Mount single file as volume to Azure Container Apps

100 views Asked by At

I am trying to run version latest tag of the image available at https://hub.docker.com/r/kernelmemory/service.

This image relies on a single file as configuration to run.

The example command to run it locally is:

docker run --volume ./appsettings.Development.json:/app/appsettings.Production.json -it --rm -p 9001:9001 kernelmemory/service:1.0

As you can see, it mounts the appsettings.Development.json file from the local host to appsettings.Production.json file on the Docker image.

Now, I want to deploy this image to Azure Container Apps. I have gone through various posts and documentation, but I couldn't find a way to mount a single file to Azure Container App, either during the deployment with Bicep or later.

Currently, I am using a FileShare as a mount.

Have you experienced this issue/limitation before? Do you have any possible workarounds or suggestions?

1

There are 1 answers

3
Arko On BEST ANSWER

Mounting a single file as a volume in Azure Container Apps directly is not currently supported, as Azure Container Apps are designed to mount directories rather than individual files. However, as a workaround you can use an Azure File Share with your single file and mount it to your Azure Container App.

Create an Azure File Share

  • Go to your storage account in the Azure portal.
  • Navigate to "File shares" and create a new file share.
  • Upload your appsettings.Development.json file to this file share. enter image description here

Mount the File Share to your Container App

When you set up your Azure Container App, you'll include the Azure File Share as a volume in the configuration. This can be done using CLI

az containerapp create \
  --name <Container-App-Name> \
  --resource-group <Resource-Group-Name> \
  --image <Container-Image> \
  --environment <Environment-Name> \
  --secrets <Your-File-Share-Access-Key-Name>=<Your-File-Share-Access-Key> \
  --volume <Volume-Name>=<File-Share-Name>:<File-Share-Mount-Path>

or from portal at the time of creation or even later under container-> volume mounts

enter image description here

Note, you'll need to create a secret containing the access key for your storage account. This secret will be used by the Container App to authenticate with the Azure File Share.

az containerapp env secret set \
  --name <Environment-Name> \
  --resource-group <Resource-Group-Name> \
  --secret-file-share-name <Your-File-Share-Access-Key-Name>=<Your-File-Share-Access-Key>

or from portal, get the access key from storage account enter image description here

and add it as a secret in your container app enter image description here

References: