copy data from app service to azure fileshare

10/1/2021

i have an app service in production and I'm switching to aks so i will be using fileshare as a volume.

How to to make a copy of a folder in my app service (exp path: /home/site/wwwroot/public) to my new azure fileshare

found the azcopy command but nothing clear about the app service part

-- gharbi.bdr
azure
azure-aks
azure-web-app-service
kubernetes

1 Answer

10/1/2021

Assuming that you are running a Linux App Service on Azure from

(exp path: /home/site/wwwroot/public)

To Web SSH to your Linux App Service, paste the following URL into your browser and replace <app-name> with your app name:

https://<app-name>.scm.azurewebsites.net/webssh/host

[For a windows container based App Service go to the Console]

Once in SSH session (or Console), please create a new fresh directory where you can mount Azure File Storage (review the Linux App Service Limitations and Windows App Service Limitations) using:

mkdir <mount-path-directory>

Use the az webapp config storage-account add command. For example:

az webapp config storage-account add --resource-group <group-name> --name <app-name> --custom-id <custom-id> --storage-type AzureFiles --share-name <share-name> --account-name <storage-account-name> --access-key "<access-key>" --mount-path <mount-path-directory>
  • --storage-type should be AzureFiles
  • --mount-path is the directory inside the Linux container to mount to Azure Storage. Do not use / (the root directory).

Verify your storage is mounted by running the following command:

az webapp config storage-account list --resource-group <resource-group> --name <app-name>

Important: The directory specified in --mount-path in the container should be empty. Any content stored in this directory is deleted when the Azure Storage is mounted (if you specify a directory under /home, for example). If you are migrating files for an existing app, make a backup of the app and its content before you begin.

Reference

Now from the SSH session (or Console) to the App Service, copy the desired source directory to the desired destination on the Azure File Storage mount using:

cp -r /source/directory /destination/directory/

Note: You can also create subdirectories in the mount path using mkdir and copy data to those subdirectories depending on your needs.

At this point, you can mount the Azure FileShare as a Persistent Volume or Inline volume in your AKS cluster.

-- Srijit_Bose-MSFT
Source: StackOverflow