Hello @William Beglen Yes, you can use System.IO classes to access files in an Azure file share from within an Azure function app. However, you will need to configure the function app to authenticate to the file share and mount it as a drive letter or UNC path. Here are the steps to do this: Create a storage account and file share in Azure if you haven't already done so. Open the Function App settings in the Azure portal and go to the "Configuration" section.
Add a new application setting with the name "STORAGE_CONNECTION_STRING" and the value set to the connection string for your storage account. You can find the connection string in the "Access keys" section of the storage account. In your function app code, use the following code to authenticate to the file share and mount it as a drive letter or UNC path:
string storageConnectionString = Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileShare fileShare = fileClient.GetShareReference("yourfilesharename");
fileShare.CreateIfNotExists();
CloudFileDirectory rootDir = fileShare.GetRootDirectoryReference();
rootDir.CreateIfNotExists();
string mappedDrive = Path.GetTempPath() + "yourfilesharename";
rootDir.Mount(mappedDrive);
This code will mount the file share at a temporary directory on the function app, which can be accessed using standard System.IO classes.
Note that if your file share is in a different Azure region than your function app, you may experience slower performance and higher latency due to network traffic. In this case, you may want to consider using the REST API interface client or a dedicated file transfer solution such as Azure File Sync or Azure Data Box.
Please mark the answer as Accepted in case it helped ! BR