How can I access a "local" path in an Azure Function?

Chris Reed 21 Reputation points
2021-12-13T16:27:47.67+00:00

I have written an Azure function to create leads in the Zoho CRM. I gotten great guidance from members here and I have one last hurdle to get over. Zoho API writes to a location it calls the Resource Path. This has to be a local path. For example, running the function in VS, I can use a path to My Documents but not a system path to the temp folder or any other. I've tried several system paths which all throw an error. The actual error is a generic API error but Zoho support has told me its an access issue?

string path = context.FunctionAppDirectory;   
string path = System.IO.Path.GetTempPath();   

The last conversation I had with support on this, they explained it as

...upon having further discussions based on your questions with my development team, I was told that it is mandatory for the resource path to be a local path (Documents path in our case) an that it is not possible to retrieve a file stored on cloud and use it with the local SDK.  

So I THINK my question is, can I create something that looks like a local path to use in my Azure Function. I was reading about mounting a Azure file share as a drive letter (https://learn.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-windows) but it seems to only work with Azure Windows servers rather than Azure Functions.

Any suggestions are appreciated.

P.S. If this can't be done, what should I move my code to?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,926 Reputation points Volunteer Moderator
    2021-12-13T18:17:25.853+00:00

    for linux hosted azure functions, you can mount azure file storage as a local file:

    https://learn.microsoft.com/en-us/azure/azure-functions/storage-considerations

    for windows hosted azure functions, you use UNC filename (network file).

    neither will solve your issue. your api seems to use the users profile to determine the location. this probably means the application needs to run under a logged in user and may actually require an active window. you might be able to get to run under a service with profile loaded.

    You should create a simple command line program and try to get it to run as a service. if you get this to run, then you can run an asp.net core website as a service. if this doesn't work, then configure the server for kiosk mode, and have the program auto start. if you need azure hosted, then you will need a virtual machine.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.