How to mount an Azure Storage File Share from a Windows Azure Function on the Consumption Plan?

AdamLeffert-5988 71 Reputation points
2022-09-22T13:55:06.43+00:00

I have a Windows Azure Function on the consumption plan.

It uses Process.Start to run a Windows .exe (app.exe). App.exe reads a local file in the temp directory and writes to the same directory. I use unique file names to keep files from different AF instances from colliding.

This works, but there is very little available drive space in the directory returned by Temp.GetFilePath.

I could use the directory returned by reading the value of the HOME environment variable. This works, but is very slow because this drive is an Azure File Share.

I created a Premium Azure Storage file share. $15 for 100 gigs for a month is a good price and plenty of space.

My goal is to mount this Azure Storage file share from the Azure Function Windows app, so App.exe can use it.

I'm familiar with Azure.Storage.Blobs, but that won't work here. I'm not writing C# code in this case. App.exe, a legacy app, expects a Windows directory with read/write permissions.

I tried running this script from a Bash shell in the Azure Portal:

az webapp config storage-account add -g myresrourcegroup -n myazurefunction -i files -t AzureFiles -a myfilestorageaccountname --sn files -k mykey -m /files

with the "my" values replaced with the correct values for my resource. I get a "bad request" error.

I tried running the standard Powershell script I would run in Windows to mount a drive, in Azure Portal Advanced Tools, but I get errors as well.

$connectTestResult = Test-NetConnection -ComputerName http://myfileshare.file.core.windows.net -Port 445
Write-Progress : Win32 internal error "The handle is invalid" 0x6 occurred
while reading the console output buffer. Contact Microsoft Customer Support
Services.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\NetTCPIP\Test-NetConnecti
on.psm1:264 char:13

  • Write-Progress -Activity $ProgressString -Status "Attempt ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ReadError: (:) [Write-Progress], HostException
  • FullyQualifiedErrorId : ReadConsoleOutput,Microsoft.PowerShell.Commands.
    WriteProgressCommand

etc.

Please advise as to the simplest way to mount an Azure Storage File Share from an Azure Function Windows on the consumption plan.

Thanks!

Adam Leffert
https://www.fullstackdeveloper.com

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,400 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,768 questions
0 comments No comments
{count} vote

Accepted answer
  1. Sumarigo-MSFT 44,096 Reputation points Microsoft Employee
    2022-09-26T07:04:59.737+00:00

    @AdamLeffert-5988 Firstly, apologies for the delay in responding here!

    It is not supported for windows consumption function. Mount file shares: This functionality is current only available when running on Linux.
    You can mount existing Azure Files shares to your Linux function apps. By mounting a share to your Linux function app, you can use existing machine learning models or other data in your functions. You can use the following command to mount an existing share to your Linux function app. File share used to store and run your function app code in a Consumption Plan and Premium Plan. Azure Files is set up by default, but you can create an app without Azure Files under certain conditions.

    If you have any additional questions or need further clarification, please let me know.

    ----------

    Please do not forget to 244712-screenshot-2021-12-10-121802.png and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


1 additional answer

Sort by: Most helpful
  1. AdamLeffert-5988 71 Reputation points
    2022-09-29T10:52:45.51+00:00

    Another thing I discovered is that yes, you can use premium storage for a Windows consumption AF, but it's $15 per month per AF ($.15 per gig, 100 gigs minimum). You can't share the same premium storage account across multiple AF's. Each AF requires its own storage account, no matter how little of the 100 gigs it uses.

    0 comments No comments