Mount Azure File share using cifs-utils and SAS Token - azure

Is it possible to mount to Azure File share using mount.cifs and SAS token instead of Storage key? I tried this out but I got a Permission Denied, so I was wondering if this is possible.
sudo mount -t cifs //<storage account>.file.core.windows.net/<file share> <local path> -o vers=3.0,username=<storage account>,password="<sas token>",dir_mode=0777,file_mode=0777,serverino

Unfortunately, it's impossible to do that. The SAS token is not supported in mounting Azure File share currently, it just supports the Azure storage account key. You can take a look at the feedback.

Related

Unmounting and Mounting fileshare in azure

I have a storage account where fileshare has been mounted which includes nearly 300+ files in that fileshare. Now if I try unmounting it with below command,
sudo umount /xyx/files
Then what is the command to mount it back? Is it
P
sudo mount /xyx/files ???
I have mounted initially from windows share to Linux OS . Do I need to use the same command or the above mount command?
If I use the same command then will there be any loss of my files?
I tried to reproduce the same in my environment I have mount a file share in storage account:
First make sure you have checked your storage account accessible from public network as below:
I tried to mount a sample file in azure storage account
I have mounted my sample files successfully as below:
To unmount the azure file share, make use of below command:
sudo umount /mnt/<yourfileshare>
In the event that any files are open, or any processes are running in the working directory, the file system cannot be unmounted.
To unmount a file share drive you can make use below command
net use <drive-letter> /delete
When you try to unmount the files once the execution has been complete the mount point will be deleted from that moment, we can't access the data through the mount point on the storage. if you want to restore the file if you have already enabled the soft delete. in file share some files are deleted in that time you can disable the soft delete and in file share you can enable show deleted shares option and you can make use of undelete.
Reference: Mount Azure Blob storage as a file system on Linux with BlobFuse | Microsoft Learn

How to mount the subpath of blockBlob container of storage account on the vm?

I have a storage account name storeabc of blockblob type inside that I have a container named testcontainer. I created a folder inside the container named testfolder.
I can successfully mount the container(till the container only). using the below command.
mount -o sec=sys,vers=3,nolock,proto=tcp storeabc.blob.core.windows.net:/storeabc/testcontainer /nfsdata
However, I was looking for a way to mount the folder i.e. testfolder.
I tried,
mount -o sec=sys,vers=3,nolock,proto=tcp storeabc.blob.core.windows.net:/storeabc/testcontainer/testfolder /nfsdata
which ends up with the error.
mount.nfs: mounting storeabc.blob.core.windows.net:/storeabc/testcontainer/testfolder failed, reason given by server: No such file or directory
TIA.
mount.nfs: mounting storeabc.blob.core.windows.net:/storeabc/testcontainer/testfolder
failed, reason given by server: No such file or directory
According to this MS-document Known issues with Network File System (NFS) 3.0 protocol support for Azure Blob Storage .you can only mount the root directory i.e (Container). Mounting sub directories in azure blob storage not yet supported.
mount -o sec=sys,vers=3,nolock,proto=tcp <storage-account-name>.blob.core.windows.net:/<storage-account-name>/<container-name> /nfsdata
Please try to type the commands and avoid copy pasting as hidden characters in that command can cause these error.
Reference:
Mount Azure Blob Storage by using the NFS 3.0 protocol | Microsoft Docs

Mounting azure blob to VM

I am trying to mount an azure blob with a Linux VM and I am successfully able to do it with the storage access key. Is there any other route to do the mount? Maybe using the SAS token or AD authentication. Any help is appreciated.
If you are using blobfuse and you want to mount a blob/container via SAS token, pls try the steps below:
create a connection.cfg file with content as official doc indicated: https://github.com/Azure/azure-storage-fuse/blob/master/connection.cfg
in my case :
Run mount command:
blobfuse /<-the path you want to mount-> --tmp-path=/mnt/blobfusetmp
-o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 --config-file=<-path of your connection.cfg file-> --log-level=LOG_DEBUG --file-cache-timeout-in-seconds=120
In my case:
blobfuse /testcontainer --tmp-path=/mnt/blobfusetmp -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 --config-file=../connection.cfg --log-level=LOG_DEBUG --file-cache-timeout-in-seconds=120
As you can see I mounted a container which named: testcontainer, and there is only one file in this container:
And this is the result of mount command:
Let me know if it works as excepted or if you need any more assistances.

SMB Client on azure server not deleting file from azure storage

I have a flask webapp running on an Ubuntu Azure sever. I also have an azure storage account, and to access the storage from the webapp, I use SMB. This has worked so far, with adding and updating files on the server, but I tried to delete a file and it didn't work. No error or anything, it just did nothing and the file is still on the server. I tried the command locally and it worked fine. Is there something I'm doing wrong and how could I fix this problem. Here's the command I've been using:
smbclient //name.file.core.windows.net/website -mSMB3 -e -Uname%password -c 'rm tempplugins/test2.ini'
This may not solve your exact problem, but I was attempting to perform operations on a file share on an Azure Storage Account from an Azure VM running CentOS, and I ran into several different problems. It took me a while to get the kinks worked out.
In my case, I had to use to use backslashes, but I had to double them so that they were escaped properly. Example:
smbclient \\\\storageaccount.file.core.windows.net\\sharename
Additionally, we weren't using an integrated active directory, and so we had to use the storage account name as the username and it had to be "prefixed" with "Azure" like "Azure\storageaccount". And don't forget that backslashes have to be doubled! Also, the password was the storage account key. Example:
smbclient \\\\storageaccount.file.core.windows.net\\sharename -U Azure\\storageaccount%key
I used the "-d" option to debug the command line options for smbclient. However, in my case, the "-d" option had to be on the end of the command or it interfered. If it hadn't been for the clues provided by "-d", I never would have gotten this to work. Example:
smbclient \\\\storageaccount.file.core.windows.net\\sharename -U Azure\\storageaccount%key -d
Here's a simple, one-liner that shows a directory of a file share on an Azure Storage Account. Example:
smbclient \\\\storageaccount.file.core.windows.net\\sharename -U Azure\\storageaccount%key -c dir -d
I hope that this helps someone else as I must of blown 2 to 3 hours to get this worked out.

Azure files giving permission denied in kubernetes

I have configured azure file volume for my pod for an application. when i try to run it, it shows error.
Warning FailedMount 0s (x7 over 32s) kubelet,
aks-nodepool1-39499429-1 MountVolume.SetUp failed for volume
"lhapidatasource" : mount failed: exit status 32
Output: mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Please help
About mount Azure file share to Azure k8s pod, please refer to this answer.
Note:
Need based64 encoded Azure storage account and key.
Write the right file share name to azure.yaml:
Hope that helps.

Resources