Hi,
The sandbox blocks the ports required for connecting to SMB share:
https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#restricted-outgoing-ports
Please click Accept Answer and upvote if the above was helpful.
Thanks.
-TP
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Title: Accessing FileShare from Azure Function App in Same VNet
Hi,
I am trying to access files in a FileShare from an Azure Function App. The FileShare is hosted inside an Azure VM, and both the VM and the Function App are within the same VNet. However, they are not in the same App Service Plan. I am using a .NET 8 Function App.
I have attempted two different code approaches, but my network engineer reports no traffic from the Azure Function. Additionally, I encounter different errors with each approach.
Could someone provide guidance on resolving this issue?
string fullPath = Path.Combine(FileSharePath, data.FilePath);
var networkCredential = new NetworkCredential("username", "password", "domain");
using (new NetworkConnection(FileSharePath, networkCredential))
{
if (File.Exists(fullPath))
{
using (var fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
{
// Do something with the fileStream
}
return new OkResult();
}
return new NotFoundObjectResult("File not found");
}
Error: Network path was not found
await using var fileStream = new FileStream(data.FilePath, FileMode.Open, FileAccess.Read);
return new OkResult();
Error: Access denied to path
Any help to tackle this challenge would be greatly appreciated.
Thank you!
Hi,
The sandbox blocks the ports required for connecting to SMB share:
https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#restricted-outgoing-ports
Please click Accept Answer and upvote if the above was helpful.
Thanks.
-TP
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
Yes, you need to mount file share before accessing it. Currently, Mount file shares are only supported for Linux Web Apps (and Windows Container Web apps), and you can follow doc: Mount file shares in setting the mount via CLI az webapp config storage-account add
(or PowerShell command).
however the alternate is to use the Storage Blob using the URL.